-
Notifications
You must be signed in to change notification settings - Fork 0
feat(handlers): add automatic cache invalidation for event args #4
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
Conversation
Implement automatic AccountId extraction from event args with centralized cache invalidation in EventProcessor. - Add tryConvertToAccountId() and extractAccountIdsFromArgs() utilities - Add additionalAccountIdsToInvalidate collector to HandlerContext - Auto-invalidate detected AccountIds after each handler execution - Migrate existing handlers to use context collector pattern - Refactor processNext() to use _executeHandler() for consistency Handlers now automatically invalidate cache for AccountIds in event args. Handlers needing calculated or DB-lookup IDs push to the context collector. This fixes splitHandler (and others) silently skipping cache invalidation. Resolves: #3
|
🚅 Environment dripfeed-pr-4 in Drips App has no services deployed. |
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.
Pull request overview
This PR implements automatic cache invalidation for event handlers by extracting AccountIds directly from event arguments, eliminating the need for manual cache invalidation calls in most handlers. The implementation adds utility functions for AccountId detection and validation, integrates centralized cache invalidation into the EventProcessor, and migrates existing handlers to use a collector pattern for additional AccountIds that require database lookups.
- Added
tryConvertToAccountId()andextractAccountIdsFromArgs()utilities for automatic AccountId extraction from event args - Refactored EventProcessor to automatically invalidate caches for detected AccountIds plus handler-specified additional IDs
- Migrated handlers (transfer, streamReceiverSeen, ownerUpdated, given, accountMetadataEmitted) to use the new
additionalAccountIdsToInvalidatecollector pattern
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/utils/accountIdUtils.ts | New utility functions for converting values to AccountIds and extracting them from event args, with validation against known driver types |
| src/handlers/EventHandler.ts | Added additionalAccountIdsToInvalidate array to HandlerContext for handlers to register AccountIds discovered via DB lookups |
| src/core/EventProcessor.ts | Integrated automatic cache invalidation after handler execution, combining auto-detected and handler-specified AccountIds; added proper array reset in batch processing |
| src/handlers/transferHandler.ts | Removed manual cache invalidation, now pushes calculated fromAccountId and ownerAccountId to collector (tokenId auto-detected) |
| src/handlers/streamReceiverSeenHandler.ts | Removed manual cache invalidation, now pushes split receiver IDs to collector (accountId auto-detected) |
| src/handlers/ownerUpdatedHandler.ts | Removed manual cache invalidation, now pushes calculated ownerAccountId to collector (accountId auto-detected) |
| src/handlers/givenHandler.ts | Removed manual cache invalidation entirely (both accountId and receiver auto-detected from args) |
| src/handlers/AccountMetadataEmitted/accountMetadataEmittedHandler.ts | Removed manual cache invalidation, now pushes split receiver IDs to collector (accountId auto-detected) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
efstajas
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.
Nice!
Implement automatic AccountId extraction from event args with centralized cache invalidation in EventProcessor.
Handlers now automatically invalidate cache for AccountIds in event args. Handlers needing calculated or DB-lookup IDs push to the context collector. This fixes splitHandler (and others) silently skipping cache invalidation.
Resolves: #3