feat(event-bus): wire SSE broadcast strategy into event bus lifecycle#2503
Merged
pedrofrxncx merged 3 commits intomainfrom Feb 26, 2026
Merged
feat(event-bus): wire SSE broadcast strategy into event bus lifecycle#2503pedrofrxncx merged 3 commits intomainfrom
pedrofrxncx merged 3 commits intomainfrom
Conversation
Introduce SSEBroadcastStrategy interface that decouples event broadcasting from the SSE hub, enabling cross-pod SSE delivery in multi-pod deployments. - SSEBroadcastStrategy interface with start/broadcast/stop lifecycle - LocalSSEBroadcast: in-memory single-process implementation - NatsSSEBroadcast: NATS pub/sub for cross-pod replication with per-instance origin ID to prevent double-emit on publisher pod - Refactor SSEHub to delegate broadcast to the pluggable strategy, separating localEmit (HTTP stream fan-out) from broadcast routing Made-with: Cursor
Select SSE broadcast strategy alongside notify strategy at startup: NATS_URL present → NatsSSEBroadcast, otherwise → LocalSSEBroadcast. - createEventBus now starts sseHub with the resolved strategy - app.ts stops sseHub during HMR cleanup to prevent leaked connections Made-with: Cursor
- Start SSE hub with LocalSSEBroadcast by default when creating EventBus - Add explicit logging for single-pod vs cross-pod SSE broadcast modes - Ensure SSE hub initializes even when custom EventBus is provided - Export SSEEvent and sseHub from event-bus module for public API Made-with: Cursor
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
Contributor
Release OptionsShould a new version be published when this PR is merged? React with an emoji to vote on the release type:
Current version: Deployment
|
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.
What is this contribution about?
This PR wires the SSE (Server-Sent Events) broadcast strategy into the event bus lifecycle, ensuring that:
Key changes:
createEventBus()and when custom EventBus is providedScreenshots/Demonstration
N/A
How to Test
bun run dev[SSEHub] Using local SSE broadcast (single-pod)[SSEHub] Using NATS SSE broadcast (cross-pod)bun test(ignoring pre-existing Playwright e2e infrastructure issues)Migration Notes
N/A - No database migrations or configuration changes required.
Review Checklist
bun run fmt)bun run lint)bun run check:ci)bun run knip)Summary by cubic
Wires a pluggable SSE broadcast strategy into the event bus so SSE events fan out across pods via NATS when available, with a local fallback. The SSE hub now starts/stops with the bus and supports hot-swapping for HMR.
New Features
Bug Fixes
Written for commit 3d7c4f9. Summary will update on new commits.