EventBus is the central runtime for handler registration, event emit, history lookup, and lifecycle control.
EventBus(...)
- Python
- TypeScript
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), the current processing bus applies its own defaults.
Runtime state
Both 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
off(...)
Unregisters handlers by event key, handler function/reference, or handler id.
- Python
- TypeScript
emit(...)
emit(...) enqueues synchronously and returns the pending event immediately.
- Python
- TypeScript
find(...)
find(...) supports history lookup, optional future waiting, predicate filtering, and parent/child scoping.
- Python
- TypeScript
Lifecycle helpers
Wait for idle
- Python
- TypeScript
Parent/child relationship checks
- Python
- TypeScript
Execution pipeline
Both runtimes use the same layered model, expressed with runtime-native wrappers.- Event scope lock
- Event-level timeout and slow monitor
- Per-handler lock
- Handler-level timeout and slow monitor
- Handler execution context scope
- Error normalization and completion callbacks
- Python
- TypeScript
Serialization and teardown
Both 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
Timeout and precedence
Shared precedence model:- Handler override
- Event override
- Bus default