Expand description
JAEB is an in-process, actor-based event bus for Tokio applications.
It supports synchronous and asynchronous listeners, explicit dependency injection via handler structs, unsubscribe handles, retry/dead-letter failure policies, and graceful shutdown.
§Requirements
An active Tokio runtime must be available when constructing an
EventBus (via new or
builder().build()), because the internal
actor task is spawned immediately via tokio::spawn. Both construction
methods return Result and validate their configuration before spawning.
§Important semantics
- Sync handlers — executed inline on the actor task (with panic
isolation via
catch_unwind) and complete beforeEventBus::publishreturns. Sync handlers execute exactly once — retries are not supported. - Async handlers — spawned into a
JoinSet;publishmay return before they finish. Async events requireE: Clonebecause the event is cloned for each handler invocation. Retries and delays are supported viaFailurePolicy. - Shutdown —
EventBus::shutdowndrains queued messages, then waits for (or aborts) in-flight async tasks. Shutdown is idempotent: subsequent calls returnOk(()). - Dead letters — after all retries are exhausted a
DeadLetteris published unless disabled. A failing dead-letter handler will not produce another dead letter (recursion is guarded).
Re-exports§
pub use bus::EventBus;pub use bus::EventBusBuilder;pub use error::ConfigError;pub use error::EventBusError;pub use error::HandlerError;pub use error::HandlerResult;pub use handler::AsyncMode;pub use handler::EventHandler;pub use handler::IntoHandler;pub use handler::SyncEventHandler;pub use handler::SyncMode;pub use subscription::Subscription;pub use subscription::SubscriptionGuard;pub use types::DeadLetter;pub use types::Event;pub use types::FailurePolicy;pub use types::SubscriptionId;