jaeb

Crates.iojaeb
lib.rsjaeb
version0.1.0
created_at2025-10-12 19:24:16.866887+00
updated_at2025-10-12 19:24:16.866887+00
descriptionsimple actor based event bus
homepage
repositoryhttps://github.com/LinkeTh/jaeb
max_upload_size
id1879573
size27,076
(LinkeTh)

documentation

README

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.

Commit count: 0

cargo fmt