events
Provides models and utilities for handling events.
Event
Bases: PlugboardBaseModel, ABC
Event is a base model for all events.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Type of the |
id |
UUID4
|
UUID v4 unique identifier for the |
timestamp |
UTCDateTime
|
UTC timestamp for the |
source |
str
|
Source of the |
version |
str
|
Version of the |
data |
dict[str, Any] | BaseModel
|
Data associated with the |
metadata |
dict[str, str]
|
Metadata for the |
SystemEvent
Bases: Event, ABC
SystemEvent is a base model for system events.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Type of the |
id |
UUID4
|
UUID v4 unique identifier for the |
timestamp |
UTCDateTime
|
UTC timestamp for the |
source |
str
|
Source of the |
version |
str
|
Version of the |
data |
dict[str, Any] | BaseModel
|
Data associated with the |
metadata |
dict[str, str]
|
Metadata for the |
StopEvent
EventConnectorBuilder
EventHandlers
EventHandlers provides a decorator for registering event handlers.
add
classmethod
get
classmethod
Retrieve a handler for a specific class and event type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_class
|
Type
|
Class to handle event for |
required |
event
|
Type[Event] | Event
|
Event class or instance to handle |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
AsyncCallable
|
The event handler method |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no handler found for class or event type |