Documentation Index
Fetch the complete documentation index at: https://abxbus.archivebox.io/llms.txt
Use this file to discover all available pages before exploring further.
Events are strongly typed and validated across the supported runtimes.
Repository example files:
Python
TypeScript
Rust
Go
from typing import Any
from abxbus import BaseEvent
class OrderCreatedEvent(BaseEvent[dict[str, Any]]):
order_id: str
customer_id: str
total_amount: float
import { BaseEvent } from 'abxbus'
import { z } from 'zod'
const OrderCreatedEvent = BaseEvent.extend('OrderCreatedEvent', {
order_id: z.string(),
customer_id: z.string(),
total_amount: z.number(),
event_result_type: z.object({ ok: z.boolean() }),
})
use abxbus_rust::{
event,
event_bus::EventBus,
BaseEvent,
};
use futures::executor::block_on;
use serde::{Deserialize, Serialize};
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
struct OrderResult {
ok: bool,
}
event! {
struct OrderCreatedEvent {
order_id: String,
customer_id: String,
total_amount: f64,
event_result_type: OrderResult,
event_result_schema: r#"{
"type": "object",
"properties": {"ok": {"type": "boolean"}},
"required": ["ok"]
}"#,
}
}
let bus = EventBus::new(Some("OrdersBus".to_string()));
bus.on(OrderCreatedEvent, |event: OrderCreatedEvent| async move {
Ok(OrderResult {
ok: event.total_amount > 0.0,
})
});
let event = bus.emit(OrderCreatedEvent {
order_id: "order-123".to_string(),
customer_id: "customer-456".to_string(),
total_amount: 42.50,
..Default::default()
});
let typed_result = block_on(event.event_result())?
.expect("handler result");
type OrderCreatedPayload struct {
OrderID string `json:"order_id"`
CustomerID string `json:"customer_id"`
TotalAmount float64 `json:"total_amount"`
}
type OrderResult struct {
OK bool `json:"ok"`
}
bus := abxbus.NewEventBus("OrdersBus", nil)
abxbus.OnTyped[OrderCreatedPayload, OrderResult](
bus,
"OrderCreatedEvent",
"handle_order",
func(payload OrderCreatedPayload) (OrderResult, error) {
return OrderResult{OK: payload.TotalAmount > 0}, nil
},
nil,
)
event, err := abxbus.NewBaseEventWithResult[OrderCreatedPayload, OrderResult]("OrderCreatedEvent", OrderCreatedPayload{
OrderID: "order-123",
CustomerID: "customer-456",
TotalAmount: 42.50,
})
if err != nil {
panic(err)
}
result, err := bus.Emit(event).EventResult()
if err != nil {
panic(err)
}
typedResult, err := abxbus.EventResultAs[OrderResult](result)
if err != nil {
panic(err)
}
_ = typedResult
- Python payload validation is powered by Pydantic models.
- TypeScript payload and result validation is powered by Zod schemas.
- Rust uses
event! to keep event fields and event metadata in one block. Primitive result schemas are derived automatically; structured result schemas are supplied through event_result_schema.
- Go uses typed struct helpers for static shape at call sites, validates typed handler payloads against the declared payload struct, and derives JSON Schema from the declared result type for runtime result validation.