| Crates.io | jaeb |
| lib.rs | jaeb |
| version | 0.1.0 |
| created_at | 2025-10-12 19:24:16.866887+00 |
| updated_at | 2025-10-12 19:24:16.866887+00 |
| description | simple actor based event bus |
| homepage | |
| repository | https://github.com/LinkeTh/jaeb |
| max_upload_size | |
| id | 1879573 |
| size | 27,076 |
Spring Boot Application Event like implementation.
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.