EventPublisher¶
- class safir.metrics.EventPublisher(application, event_class)¶
Bases:
Generic[P]Interface for event publishers.
Represents a generic publisher of application metrics events.
- Parameters:
application (
str) – Name of the application to include in events.event_class (
type[TypeVar(P, bound=EventPayload)]) – Fully-enriched class to which payloads will be converted before publication.
Methods Summary
construct_event(payload)Construct the full event as it will be published.
publish(payload)Publish an event payload.
Methods Documentation
- construct_event(payload)¶
Construct the full event as it will be published.
- Parameters:
pyaload – Payload to publish.
payload (
TypeVar(P, bound=EventPayload))
- Returns:
Enriched event model including generic metadata and Avro schema configuration.
- Return type:
- abstractmethod async publish(payload)¶
Publish an event payload.
- Parameters:
payload (
TypeVar(P, bound=EventPayload)) – Payload to publish.- Returns:
Full, enriched-with-metadata event model that was published. This will be an object of a class derived from both the type of the payload and
EventMetadata, but it is typed as the latter since that is the newly-added information that may be of interest to the caller and therefore the most likely to be accessed.- Return type: