Skip to content

Conversation

@jtourkos
Copy link
Contributor

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

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
@jtourkos jtourkos requested a review from Copilot December 22, 2025 11:16
@railway-app
Copy link

railway-app bot commented Dec 22, 2025

🚅 Environment dripfeed-pr-4 in Drips App has no services deployed.

Copy link

Copilot AI left a 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() and extractAccountIdsFromArgs() 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 additionalAccountIdsToInvalidate collector 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.

@jtourkos jtourkos requested a review from efstajas December 22, 2025 11:22
Copy link
Contributor

@efstajas efstajas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@efstajas efstajas merged commit 37dce93 into main Jan 8, 2026
9 checks passed
@efstajas efstajas deleted the feat/automatic-cache-invalidation branch January 8, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache not invalidated on repo owner update

3 participants