Events
provide.foundation.hub.events
¶
TODO: Add module docstring.
Classes¶
Event
¶
Base event class for all system events.
EventBus
¶
Thread-safe event bus for decoupled component communication.
Uses weak references to prevent memory leaks from event handlers.
Initialize empty event bus.
Source code in provide/foundation/hub/events.py
Functions¶
clear
¶
Clear all event subscriptions.
This is primarily used during test resets to prevent duplicate event handlers from accumulating across test runs.
Source code in provide/foundation/hub/events.py
emit
¶
Emit an event to all subscribers.
Handler errors are logged but do not prevent other handlers from running. This ensures isolation - one failing handler doesn't break the entire event system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Event | RegistryEvent
|
Event to emit |
required |
Source code in provide/foundation/hub/events.py
force_cleanup
¶
get_error_stats
¶
Get error statistics for monitoring handler failures.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with error statistics including: |
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in provide/foundation/hub/events.py
get_memory_stats
¶
Get memory usage statistics for the event bus.
Source code in provide/foundation/hub/events.py
subscribe
¶
Subscribe to events by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Name of event to subscribe to |
required |
handler
|
Callable[[Event], None]
|
Function to call when event occurs |
required |
Source code in provide/foundation/hub/events.py
unsubscribe
¶
Unsubscribe from events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Name of event to unsubscribe from |
required |
handler
|
Callable[[Event], None]
|
Handler function to remove |
required |
Source code in provide/foundation/hub/events.py
Functions¶
emit_registry_event
¶
Emit a registry operation event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Type of operation (register, remove, etc.) |
required |
item_name
|
str
|
Name of the registry item |
required |
dimension
|
str
|
Registry dimension |
required |
**kwargs
|
Any
|
Additional event data |
{}
|