Skip to content

feat(cache): Add in memory cache#639

Merged
jdenquin merged 64 commits intomainfrom
cache-initial-snapshot
Apr 27, 2026
Merged

feat(cache): Add in memory cache#639
jdenquin merged 64 commits intomainfrom
cache-initial-snapshot

Conversation

@jdenquin
Copy link
Copy Markdown
Contributor

No description provided.

@jdenquin jdenquin requested a review from Copilot November 21, 2025 16:57
Copy link
Copy Markdown

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 pull request introduces an in-memory cache system for the events processor to improve performance by reducing database queries. The cache uses BadgerDB for storage and implements Change Data Capture (CDC) via Debezium to keep cached data synchronized with the database in real-time.

Key Changes

  • Implemented a BadgerDB-based in-memory cache with snapshot loading and CDC consumption
  • Added utility types (NullTime, StringArray) for JSON serialization/deserialization and database operations
  • Integrated cache usage in event enrichment services to replace direct database lookups
  • Updated dependency versions in go.mod/go.sum

Reviewed changes

Copilot reviewed 45 out of 46 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
events-processor/cache/*.go Core cache implementation with model-specific operations and CDC consumers
events-processor/models/*.go Added streaming query utilities and updated models with new JSON tags
events-processor/utils/*.go New utility types for nullable time and string arrays
events-processor/main.go Cache initialization and lifecycle management
events-processor/processors/*.go Integration of cache into event processing pipeline
extra/debezium_config.json Debezium CDC configuration for Kafka topics
events-processor/go.mod Updated dependencies including BadgerDB and OpenTelemetry

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread events-processor/cache/cache.go Outdated
Comment thread events-processor/cache/cache.go Outdated
Comment thread events-processor/cache/billable_metrics_test.go Outdated
Base automatically changed from kafka-connect to main November 25, 2025 11:18
@jdenquin jdenquin force-pushed the cache-initial-snapshot branch from 0d32942 to d3b2b19 Compare November 28, 2025 14:38
@jdenquin jdenquin marked this pull request as ready for review November 28, 2025 14:39
@jdenquin jdenquin requested a review from Copilot November 28, 2025 14:42
Copy link
Copy Markdown

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

Copilot reviewed 48 out of 49 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

events-processor/models/query_streaming.go:1

  • Debug print statement left in production code. This should be removed or replaced with proper logging using the logger instance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread events-processor/cache/flat_filters_test.go Outdated
Comment thread events-processor/cache/subscriptions.go Outdated
Copy link
Copy Markdown
Contributor

@groyoh groyoh left a comment

Choose a reason for hiding this comment

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

Be careful, you updated the submodules.

Comment thread events-processor/utils/time_test.go
Comment thread events-processor/mise.toml Outdated
Comment thread events-processor/README.md Outdated
Comment thread events-processor/cache/subscriptions.go Outdated
Comment thread events-processor/processors/events_processor/enrichment_service.go Outdated
Comment thread events-processor/cache/subscriptions.go
Comment thread events-processor/cache/consumer.go
Comment thread events-processor/processors/events_processor/processor_test.go
Copy link
Copy Markdown
Contributor

@groyoh groyoh left a comment

Choose a reason for hiding this comment

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

Review done by Claude Code

Good work overall on this cache layer — the generic ConsumerConfig[T] / LoadSnapshot[T] patterns, the TTL-based soft delete for subscriptions, and the feature-flag gating are all solid choices.

A few issues below that I think should be addressed before merging, primarily around correctness differences between the cache and DB paths.


🟡 Removed test coverage for the reprocess scenario (processor_test.go)

The "When reprocess flag is set, only produces to enriched expanded topic" test was removed and not re-added in the new structure. This loses coverage for the reprocess functionality (checking that enrichedProducer, inAdvanceProducer, and cacheStore are NOT called, and only enrichedExpandedProducer is).

Comment thread events-processor/cache/subscriptions.go Outdated
Comment thread events-processor/cache/subscriptions.go
Comment thread events-processor/cache/subscriptions.go
Comment thread events-processor/cache/subscriptions.go
Comment thread events-processor/processors/events_processor/enrichment_service.go Outdated
Comment thread events-processor/models/query_streaming.go
@jdenquin jdenquin merged commit fff5858 into main Apr 27, 2026
1 check passed
@jdenquin jdenquin deleted the cache-initial-snapshot branch April 27, 2026 12:47
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.

4 participants