KafkaEventPublisher¶
- class safir.metrics.KafkaEventPublisher(*, application, manager, event_class, publisher, schema_info)¶
Bases:
EventPublisher
,Generic
[P
]Publishes one type of event.
You shouldn’t need to instantiate instances of this class yourself. Instead, call
create_publisher
. This object wraps a FastStream publisher, schema information, and the underlying event manager that will be used to publish events.- Parameters:
application (
str
) – Name of the application publishing events.manager (
KafkaEventManager
) – The EventManager that will actually publish the event to Kafkaevent_class (
type
[TypeVar
(P
, bound=EventPayload
)]) – AnAvroBaseModel
with the fields from the payload,EventMetadata
, and an innerMeta
class with additional schema configuration.publisher (
AsyncAPIDefaultPublisher
) – FastStream publisher to use to publish the event to Kafka. This contains Kafka metadata, like the topic to publish to.schema_info (
SchemaInfo
) – Confluent schema information for this event type.
Methods Summary
publish
(payload)Publish an event payload.
Methods Documentation
- 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: