Expand description
§Polarway Bus — Generic Event Fan-Out
A domain-agnostic event bus with:
- Broadcast fan-out: every subscriber gets every event (unless filtered).
- Per-subscriber drain buffers: subscribers can drain all pending events in one batch call (no async required).
- Filter predicates: subscribers can register a filter closure to ignore irrelevant events.
- Back-pressure policy: configurable behavior when a subscriber falls behind.
§Design Principles
- Generic over event type
T: Clone + Send + Sync + 'static - No finance-specific code — usable for signals, logs, metrics, or any domain
- Railway-oriented: methods return
Resultwhere appropriate - Efficient: uses
tokio::sync::broadcastfor the hot path
Structs§
- Event
Bus - A generic, domain-agnostic event bus.
- Filtered
Subscriber - A filtered subscriber that only buffers events passing a predicate.
- Subscriber
- An unfiltered subscriber that accumulates events for sync drain.
Enums§
- BusError
- Errors that can occur during bus operations.
Type Aliases§
- BusResult
- Result type for bus operations.