Skip to main content

Crate jaeb

Crate jaeb 

Source
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 before EventBus::publish returns. Sync handlers execute exactly once — retries are not supported.
  • Async handlers — spawned into a JoinSet; publish may return before they finish. Async events require E: Clone because the event is cloned for each handler invocation. Retries and delays are supported via FailurePolicy.
  • ShutdownEventBus::shutdown drains queued messages, then waits for (or aborts) in-flight async tasks. Shutdown is idempotent: subsequent calls return Ok(()).
  • Dead letters — after all retries are exhausted a DeadLetter is 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;

Modules§

bus
error
handler
subscription
types