pythia.event_stream.kafka#
kafka-backed event stream storage.
- class pythia.event_stream.kafka.Backend(uri: str)[source]#
Bases:
Backend
Simple backend to post messages using
KafkaProducer
.Initialize a backend from its uri.
- Parameters:
uri – connection string.
- _abc_impl = <_abc_data object>#
- _client: KafkaProducer | None = None#
- property bootstrap_servers: List[str]#
port’.
- Returns:
- Single-element list containing a connection of the form
’host:port’
- Type:
Singular list containing ‘host
- property client: KafkaProducer#
Kafka producer lazy-loader.
- Returns:
- Initialized producer, guaranteed to be both connected and
have the stream created as a topic.
- connect() None [source]#
Instantiate a topic connected kafkaproducer.
This method is in charge of creating the producer, making sure it is properly connected, and ensure the topic which is used to post messages actually exists, creating it otherwise.
- Raises:
ConnectionError – kafka producer is not ‘bootstrap_connected’
- property host: str#
Exctract the ‘host’ from the netloc in the uri.
- Returns:
The host contained in the uri’s netloc.
- property port: int#
Exctract the ‘port’ from the netloc in the uri.
- Returns:
The port contained in the uri’s netloc.