Repository navigation
FEAT: Issue #5 — Redis Pub/Sub Integration for Real-Time Broadcasting - #11
Merged
Merged
Conversation
**Overview:**
Connects Redis pub/sub to WebSocket hub for multi-instance broadcasting.
Enables horizontal scaling and real-time leaderboard updates across all backend replicas.
**Implementation:**
- internal/ws/pubsub.go: Redis pub/sub client layer
- NewPubSub(): connects to Redis with fallback
- Publish(): sends message to Redis channel
- PublishLeaderboardUpdate(): broadcasts to all instances
- Subscribe(): listens and forwards to local WebSocket hub
- Updated handlers: all broadcasts now dual-channel
- CreateProposal: publishes to intent:{id} channel
- SelectWinner: publishes winner selection
- SettleExecution: publishes settlement
- Updated server initialization
- Server.New() initializes Redis pub/sub on startup
- Server.Shutdown() closes Redis connection gracefully
**Architecture:**
Agent submits proposal
├→ h.hub.Broadcast() (local WebSocket clients)
└→ h.pubsub.Publish() (Redis pub/sub channel)
↓
Other backend instances receive & forward
to their local WebSocket subscribers
Result: All dApp users see real-time updates
**Scaling:**
- Multiple backend replicas share single Redis instance
- No message loss (Redis is source of truth)
- No data inconsistency (all clients get same update)
- Ready for horizontal deployment (K8s, docker-compose)
**Testing:**
✓ Server starts with Redis connection
✓ Proposals broadcast to local + Redis
✓ Build successful (no compilation errors)
**Next:**
- Issue #6: Scoring engine (deterministic proposal selection)
- Issue #7: Execution validation (constraint enforcement)
- Issue #8: Circle integration (wallet + USDC settlement)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview:
Connects Redis pub/sub to WebSocket hub for multi-instance broadcasting. Enables horizontal scaling and real-time leaderboard updates across all backend replicas.
Implementation:
internal/ws/pubsub.go: Redis pub/sub client layer
Updated handlers: all broadcasts now dual-channel
Updated server initialization
Architecture:
Agent submits proposal
├→ h.hub.Broadcast() (local WebSocket clients)
└→ h.pubsub.Publish() (Redis pub/sub channel)
↓
Other backend instances receive & forward
to their local WebSocket subscribers
Result: All dApp users see real-time updates
Scaling:
Testing:
✓ Server starts with Redis connection
✓ Proposals broadcast to local + Redis
✓ Build successful (no compilation errors)
Next:
close #5