polarway_bus/lib.rs
1//! # Polarway Bus — Generic Event Fan-Out
2//!
3//! A domain-agnostic event bus with:
4//! - **Broadcast fan-out**: every subscriber gets every event (unless filtered).
5//! - **Per-subscriber drain buffers**: subscribers can drain all pending events
6//! in one batch call (no async required).
7//! - **Filter predicates**: subscribers can register a filter closure to ignore
8//! irrelevant events.
9//! - **Back-pressure policy**: configurable behavior when a subscriber falls behind.
10//!
11//! ## Design Principles
12//!
13//! - Generic over event type `T: Clone + Send + Sync + 'static`
14//! - No finance-specific code — usable for signals, logs, metrics, or any domain
15//! - Railway-oriented: methods return `Result` where appropriate
16//! - Efficient: uses `tokio::sync::broadcast` for the hot path
17
18mod bus;
19mod subscriber;
20mod error;
21
22pub use bus::EventBus;
23pub use subscriber::{Subscriber, FilteredSubscriber};
24pub use error::BusError;
25
26/// Result type for bus operations.
27pub type BusResult<T> = Result<T, BusError>;