-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Use extended cache for caching integration configuration details #6650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use extended cache for caching integration configuration details #6650
Conversation
|
Claude finished @brant-livefront's task —— View job Code Review Complete ✅I've conducted a comprehensive code review of this PR. Overall, this is a well-structured migration to extended cache with significant benefits. The implementation is solid with good test coverage and clear documentation updates. 📊 SummaryThis PR successfully migrates event integration configuration caching from a custom in-memory solution to the extended cache system (FusionCache). The key improvement is consolidating two separate cache lookups into a single call that retrieves both explicit event type matches and wildcard (null event type) matches in one query. Key Changes:
✅ Strengths1. Excellent Architecture DecisionThe migration to extended cache provides significant benefits:
2. Query OptimizationThe latest commit (395b9ad) improves efficiency by:
3. Strong Test CoverageThe test suite is comprehensive with 224 added lines covering:
4. Documentation ExcellenceThe README.md updates clearly explain:
🔍 Issues Found
|
...zationIntegrationConfigurationDetailsReadManyWildcardByOrganizationIdIntegrationTypeQuery.cs
Outdated
Show resolved
Hide resolved
|
New Issues (2)Checkmarx found the following issues in this Pull Request
Fixed Issues (3)Great job! The following issues were fixed in this Pull Request
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6650 +/- ##
==========================================
- Coverage 57.27% 57.27% -0.01%
==========================================
Files 1917 1916 -1
Lines 85518 85471 -47
Branches 7673 7672 -1
==========================================
- Hits 48983 48954 -29
+ Misses 34691 34672 -19
- Partials 1844 1845 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| @@ -0,0 +1,19 @@ | |||
| CREATE OR ALTER PROCEDURE [dbo].[OrganizationIntegrationConfigurationDetails_ReadManyWildcardByOrganizationIdIntegrationType] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this stored procedure name appropriate? With 3 predicates in the where clause, will there be more than 1 result per OrganiztionId and IntegrationType? Also, in ReadManyWildcard, we don't use Wildcard anywhere else in the DB. It's fine if it's applicable, just haven't seen it before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was good with the name when I first read it to make the openness clear, but yeah we can probably just get rid of "wildcard". Yes, there will be many.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wasn't 100% sold on "Wildcard" either. I landed on that to call out that we're fetching ones where EventType is explicitly null, which we treat as a wildcard event - they match all events. I'd be up for dropping it if we think it's misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, just get rid of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest commit has a refactor to remove references to "wildcard". 👍
withinfocus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't formally request changes since we were discussing this on Slack, but my primary request besides my current inline comments was that we need a service or CQRS to be in place here for the cache invocations -- they should not be out at the edge in controllers.
| integrationType: integrationType, | ||
| eventType: eventMessage.Type | ||
| ), | ||
| options: new FusionCacheEntryOptions(duration: TimeSpan.FromDays(1)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎨 Cache constant for all these.
| @@ -0,0 +1,19 @@ | |||
| CREATE OR ALTER PROCEDURE [dbo].[OrganizationIntegrationConfigurationDetails_ReadManyWildcardByOrganizationIdIntegrationType] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was good with the name when I first read it to make the openness clear, but yeah we can probably just get rid of "wildcard". Yes, there will be many.
|
Claude's issues 1 and 5 are both addressed in the follow on PR for this: #6675 The other Claude comments I'm fine with as-is, but let me know if anyone has concerns. |
c3da3d7 to
bff0c3d
Compare
|
@withinfocus et al - I've pulled all of the Controller / API related changes out of this PR. I'll put those up (with the CQRS changes) in two separate PRs. But I wanted to slim this one down to just the DB changes, the EventIntegrationHandler changes and some fixes / supporting changes for those. |
...egrationConfigurationDetails_ReadManyConfigurationDetailsByOrganizationIdIntegrationType.sql
Outdated
Show resolved
Hide resolved
src/Core/AdminConsole/Services/Implementations/EventIntegrations/EventIntegrationHandler.cs
Outdated
Show resolved
Hide resolved
…gurations for an event (including wildcards)
|
I spoke with @withinfocus and we've altered the strategy a bit, and the latest commit executes on this direction. Instead of making 2 calls to the cache (one to fetch matching records that explicitly match the event type and a second call to fetch the records that match with a null event type) we are simply combining this into one call. The net-net is I've removed all of my new stored procedure / method / query setup (which fetched only null event types). Instead, this PR now updates the existing stored procedure to include the "wildcard" matches that have null event type. So that becomes the one call we are making to the cache and then to the repository. Before:
After:
This is obviously effect the cache clearing, but that is being handled in the PRs that are dependent on this. I'm making those updates next. |
withinfocus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest commit looks good, but bump the date on the stored proc migration -- won't be an issue in practice but the current date is pretty drifted.


📔 Objective
This PR moves the most high-traffic piece of event integrations over to the new extended cache. This part is the processing that happens every time when receive an event. We need to fetch the integrations from the database and determine if an integration should be fire. Previously, we had a home-grown database that would load all integrations into memory on a fixed interval. This PR replaces that with extended cache.
There are a number of benefits to having this in extended cache:
In addition I've cleaned up the docs and fixed an error that I noticed while testing this (Trying to create an integration of the same type as an existing one would 500 error. It now returns a
BadRequestException- and we have a new test to validate that)Finally, I have updated the method / stored procedure / query for fetching configurations. It now includes configurations where EventType is
null, which match all events. So asking for all the configurations that match a specific event type, integration type and organization id will retrieve:Note: I've moved the changes for Controllers (the write side of this PR) into 2 separate PRs since the changes were large. They will follow this PR shortly.
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes