jaeb 0.1.0

simple actor based event bus
Documentation
jaeb-0.1.0 has been yanked.

JAEB - Just Another Event Bus

Spring Boot Application Event like implementation.


Work in progress.


Setup event bus and bootstrap listeners

#[tokio::main]
async fn main() {
    let bus = EventBus::new(64);
    // Automatically registers all #[event_listener] functions in the binary
    bootstrap_listeners!(&bus);
}

Mark event listener functions.

#[event_listener]
async fn on_checkout_async(e: OrderCheckOutEvent) {
    // do async work, e.g. send email, call another service
    info!("async: order {} checked out", e.order_id);
}

#[event_listener]
fn on_checkout(e: &OrderCheckOutEvent) {
    // do synchronous side effects
    info!("sync: order {} checked out", e.order_id);
}

Publish events

async fn checkout(order_id: i32, bus: &EventBus) {
    // domain logic ...
    bus.publish(OrderCheckOutEvent { order_id }).await;
}

This waits for synchronous listeners to complete, but may return before asynchronously-registered listeners finish their work.