feat(sse): broadcast topic-resubscribe via Redis for multi-replica (ADR-0001)#206
Merged
Conversation
…DR-0001) Channel CRUD used to call UpdateUserTopicSubscriptions directly, which no-ops unless the request-serving process holds the user''s SSE connection — correct at replicas=1, silently stale at replicas>1 (the connection-holding replica keeps serving old topics until reconnect). Publish the user''s sub on a new sse:ctl:resubscribe channel instead. Every replica''s hub listener receives it and refreshes locally; replicas without a connection for that user no-op exactly as before. Falls back to the direct local call if the publish fails, so a Redis hiccup never makes a single replica worse than the old behavior. Extract the listener loop body into handleTopicMessage so the routing is testable without a live Redis subscription; cover publish, refresh- when-connected (integration-gated), no-op-when-absent, and the pre-existing cdc:core:user:* dispatch path. Implements action item 1 of docs/adr/0001-sse-multi-replica.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3 tasks
doughknee
added a commit
that referenced
this pull request
Jun 10, 2026
…uts (#208) Implements action items 3 and 5 of docs/adr/0001-sse-multi-replica.md. Prereqs landed first: sse:ctl:resubscribe control channel (#206) and Redis-backed rate-limit counters (#207). With those in, no remaining core-api state assumes a single pod. - replicas: 2 with maxUnavailable: 0 / maxSurge: 1 so deploys never drop below capacity; SSE clients ride through on their 3s retry - PodDisruptionBudget (minAvailable: 1) so node drains and cluster upgrades cannot take the whole API down - cdc-runbook diagram now shows the per-replica Redis pub/sub fan-out and the resubscribe control channel Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Action item 1 of ADR-0001 — fixes the one real multi-replica correctness bug before scaling core-api past one pod.
UpdateUserTopicSubscriptionsdirectly, which no-ops unless the request-serving process holds the user's SSE connection (events.go). Correct atreplicas: 1; atreplicas: 2a config change served by pod A leaves pod B's registry stale until the client reconnectssse:ctl:resubscribeRedis channel; every replica's hub listener handles it and refreshes locally. Replicas without that user's connection no-op exactly as before, so the broadcast is safehandleTopicMessageso routing is testable without a live Redis subscriptionTest plan
cdc:core:user:*dispatch pathgo vet+ full unit suite pass locally🤖 Generated with Claude Code