InMemoryEventBus currently uses fire-and-forget async handler execution to keep publishers non-blocking. This works now but will not scale safely once WebSocket broadcasting and higher event volume are introduced.
Current State
Publish spawns async handler tasks directly
- No internal queue or backpressure
- No safe unsubscribe / lifecycle handling
- Publishers are non-blocking (must remain so)
Problem
- Unbounded task creation under load
- No control over scheduling or throttling
- Unsafe for long-lived WebSocket handlers
- No graceful shutdown or drain support
Goal
- Keep publishers non-blocking
- Enqueue events internally (e.g.
Channel<IEvent>)
- Centralize dispatch execution
- Allow future throttling, backpressure, and safe unsubscribe
InMemoryEventBuscurrently uses fire-and-forget async handler execution to keep publishers non-blocking. This works now but will not scale safely once WebSocket broadcasting and higher event volume are introduced.Current State
Publishspawns async handler tasks directlyProblem
Goal
Channel<IEvent>)