EventBus is the central runtime for handler registration, event emit, history lookup, and lifecycle control.
EventBus(...)
- Python
- TypeScript
- Go
- Rust
Shared configuration semantics
| Option | Description |
|---|---|
name | Human-readable bus name used in logs/labels. |
event_concurrency | Event scheduling policy across queue processing (global-serial, bus-serial, parallel). |
event_handler_concurrency | How handlers for one event execute (serial vs parallel). |
event_handler_completion | Completion mode (all waits for all handlers, first resolves on first successful result). |
event_timeout | Default outer timeout budget for event/handler execution. |
event_slow_timeout | Slow-event warning threshold. |
event_handler_slow_timeout | Slow-handler warning threshold. |
event_handler_detect_file_paths | Whether to capture source path metadata for handlers. |
max_history_size | Maximum retained history (null = unbounded, 0 = keep only in-flight). |
max_history_drop | If true, drop oldest history entries when full; if false, reject new emits at limit. |
middlewares | Ordered middleware instances (or middleware classes/constructors) that receive lifecycle hooks. |
None/null/zero-value mode), the current processing bus applies its own defaults, so forwarded events can inherit the target bus defaults.
Runtime state
All implementations expose equivalent runtime state:- Bus identity:
id,name,label - Registered handlers and indexes
- Event history and pending queue
- In-flight tracking
- Locking/concurrency runtime objects
on(...)
Registers a handler for an event key (EventClass, event type string, or '*').
- Python
- TypeScript
- Go
- Rust
off(...)
Unregisters handlers by event key, handler function/reference, or handler id.
- Python
- TypeScript
- Go
- Rust
emit(...)
emit(...) enqueues synchronously and returns the pending event immediately.
- Python
- TypeScript
- Go
- Rust
find(...)
find(...) supports history lookup, optional future waiting, predicate filtering, and parent/child scoping.
- Python
- TypeScript
- Go
- Rust
filter(...)
filter(...) takes the same arguments as find(...) but returns the list of all matching
events (newest to oldest) instead of just the first match. Accepts an additional limit
argument to cap the result count.
- Python
- TypeScript
- Go
- Rust
Lifecycle helpers
Wait for idle
- Python
- TypeScript
- Go
- Rust
Parent/child relationship checks
- Python
- TypeScript
- Go
- Rust
Execution pipeline
All runtimes expose the same public processing contract:emit(...)accepts the event, records it in bus history, and queues it for processing.find(...)can observe accepted events before handlers finish.- Event-level timeout and slow-warning settings apply to the whole event.
- Handler-level timeout and slow-warning settings apply to each handler.
event_concurrency,event_handler_concurrency, andevent_handler_completionchoose queueing and completion behavior.- Handler return values and errors are stored in
event_results; use the result helpers to retrieve typed raw values.
Serialization and teardown
All runtimes can serialize the entire bus state (config, handlers metadata, event history, pending queue), restore it, re-attach handler callables, and continue processing.- Python
- TypeScript
- Go
- Rust
destroy(...)
Destroy stops runtime work and optionally clears bus-owned state.
- Python
- TypeScript
- Go
- Rust
cleardefaults totruein every runtime.- With
clear=true, destroy is terminal and clears handlers, history, queues, in-flight tracking, waiters, locks, and dispatch/context state so the bus can be released. - With
clear=false, destroy is still terminal and the bus cannot be used again; it only preserves handlers/history for inspection. - Destroying one bus only clears that bus’s local state; shared event objects, handler functions, and other buses are not destroyed.
Timeout and precedence
Shared precedence model:- Handler override
- Event override
- Bus default