Skip to content

feat: Redis Cluster support and global event deduplication#368

Open
Vvictor-commits wants to merge 1 commit intoEDOHWARES:mainfrom
Vvictor-commits:feat/redis-cluster-deduplication
Open

feat: Redis Cluster support and global event deduplication#368
Vvictor-commits wants to merge 1 commit intoEDOHWARES:mainfrom
Vvictor-commits:feat/redis-cluster-deduplication

Conversation

@Vvictor-commits
Copy link
Copy Markdown

  • Add src/config/redis.js: shared factory that creates a Redis.Cluster when REDIS_CLUSTER_NODES is set, otherwise falls back to standalone. All Redis consumers now use this single factory.

  • Add src/services/deduplication.service.js:

    • isDuplicate(): atomic SET NX EX to mark events as seen with TTL
    • acquireLock(): distributed lock with Lua-script safe release
  • Wire deduplication into poller.js: isDuplicate() is checked before processEvent() for both regular and sequence-correlated events.

  • Refactor queue.js, processor.js, correlation.service.js to use the shared redis factory instead of inline Redis instantiation.

  • Update .env.example with REDIS_CLUSTER_NODES, DEDUP_TTL_SECONDS, DEDUP_LOCK_TTL_SECONDS.

  • Add tests/deduplication.test.js (6 tests, fully mocked).

  • Fix tests/queue.test.js to match current multi-network queue API.

closes #256

- Add src/config/redis.js: shared factory that creates a Redis.Cluster
  when REDIS_CLUSTER_NODES is set, otherwise falls back to standalone.
  All Redis consumers now use this single factory.

- Add src/services/deduplication.service.js:
  - isDuplicate(): atomic SET NX EX to mark events as seen with TTL
  - acquireLock(): distributed lock with Lua-script safe release

- Wire deduplication into poller.js: isDuplicate() is checked before
  processEvent() for both regular and sequence-correlated events.

- Refactor queue.js, processor.js, correlation.service.js to use
  the shared redis factory instead of inline Redis instantiation.

- Update .env.example with REDIS_CLUSTER_NODES, DEDUP_TTL_SECONDS,
  DEDUP_LOCK_TTL_SECONDS.

- Add __tests__/deduplication.test.js (6 tests, fully mocked).
- Fix __tests__/queue.test.js to match current multi-network queue API.
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@Vvictor-commits Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Backend: Redis Cluster for Global Event Deduplication

2 participants