Skip to content

Conversation

@Savid
Copy link
Member

@Savid Savid commented Jan 30, 2026

Replace manual SetNX/Lua script implementation with github.com/go-redsync/redsync/v4 for distributed mutex handling.

Changes:

  • Add redsync v4.15.0 dependency
  • Simplify Elector interface: remove LeadershipChannel() and GetLeaderID()
  • Rewrite RedisElector using redsync.Mutex with:
    • WithSetNXOnExtend() for Redis restart resilience
    • WithDriftFactor(0.01) for clock drift safety
    • WithTries(1) for non-blocking acquisition attempts
  • Update tests to use callback-based notification only
  • Reduce implementation from ~374 to ~260 lines

Breaking changes:

  • LeadershipChannel() removed (use OnLeadershipChange callback instead)
  • GetLeaderID() removed (redsync uses opaque internal values)

Replace manual SetNX/Lua script implementation with github.com/go-redsync/redsync/v4
for distributed mutex handling.

Changes:
- Add redsync v4.15.0 dependency
- Simplify Elector interface: remove LeadershipChannel() and GetLeaderID()
- Rewrite RedisElector using redsync.Mutex with:
  - WithSetNXOnExtend() for Redis restart resilience
  - WithDriftFactor(0.01) for clock drift safety
  - WithTries(1) for non-blocking acquisition attempts
- Update tests to use callback-based notification only
- Reduce implementation from ~374 to ~260 lines

Breaking changes:
- LeadershipChannel() removed (use OnLeadershipChange callback instead)
- GetLeaderID() removed (redsync uses opaque internal values)
@Savid Savid force-pushed the refactor/redsync-leader-election branch from 0e66b58 to fac83cf Compare January 30, 2026 08:03
@Savid Savid merged commit 681625c into release/embed-mode-structlog-agg Jan 30, 2026
3 checks passed
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.

3 participants