userver: testsuite.databases.kafka.classes.KafkaProducer Class Reference
Loading...
Searching...
No Matches
testsuite.databases.kafka.classes.KafkaProducer Class Reference

Detailed Description

Kafka producer wrapper.

Definition at line 39 of file classes.py.

Public Member Functions

 __init__ (self, bool enabled, str bootstrap_servers)
 start (self)
 send (self, str topic, str|bytes key, str|bytes value, int|None partition=None, Headers|None headers=None)
 Sends the message (value) to topic by key and, optionally, to a given partition and waits until it is delivered.
 send_async (self, str topic, str|bytes key, str|bytes value, int|None partition=None, Headers|None headers=None)
 Sends the message (value) to topic by key and, optionally, to a given partition and returns the future for message delivery awaiting.
 aclose (self)

Public Attributes

 producer

Protected Member Functions

 _flush (self)

Protected Attributes

 _enabled = enabled
 _bootstrap_servers = bootstrap_servers

Constructor & Destructor Documentation

◆ __init__()

testsuite.databases.kafka.classes.KafkaProducer.__init__ ( self,
bool enabled,
str bootstrap_servers )

Definition at line 44 of file classes.py.

Member Function Documentation

◆ _flush()

testsuite.databases.kafka.classes.KafkaProducer._flush ( self)
protected

Definition at line 115 of file classes.py.

◆ aclose()

testsuite.databases.kafka.classes.KafkaProducer.aclose ( self)

Definition at line 119 of file classes.py.

◆ send()

testsuite.databases.kafka.classes.KafkaProducer.send ( self,
str topic,
str | bytes key,
str | bytes value,
int | None partition = None,
Headers | None headers = None )

Sends the message (value) to topic by key and, optionally, to a given partition and waits until it is delivered.

If the call is successfully awaited, message is guaranteed to be delivered.

:param topic: topic name. :param key: key. Needed to determine message's partition. :param value: message payload. Must be valid UTF-8. :param partition: Optional message partition. If not passed, determined by internal partitioner depends on key's hash.

Definition at line 56 of file classes.py.

◆ send_async()

testsuite.databases.kafka.classes.KafkaProducer.send_async ( self,
str topic,
str | bytes key,
str | bytes value,
int | None partition = None,
Headers | None headers = None )

Sends the message (value) to topic by key and, optionally, to a given partition and returns the future for message delivery awaiting.

:param topic: topic name. :param key: key. Needed to determine message's partition. :param value: message payload. Must be valid UTF-8. :param partition: Optional message partition. If not passed, determined by internal partitioner depends on key's hash.

Definition at line 83 of file classes.py.

◆ start()

testsuite.databases.kafka.classes.KafkaProducer.start ( self)

Definition at line 48 of file classes.py.

Member Data Documentation

◆ _bootstrap_servers

testsuite.databases.kafka.classes.KafkaProducer._bootstrap_servers = bootstrap_servers
protected

Definition at line 46 of file classes.py.

◆ _enabled

testsuite.databases.kafka.classes.KafkaProducer._enabled = enabled
protected

Definition at line 45 of file classes.py.

◆ producer

testsuite.databases.kafka.classes.KafkaProducer.producer
Initial value:
= aiokafka.AIOKafkaProducer(
bootstrap_servers=self._bootstrap_servers,
linger_ms=0, # turn off message buffering
)

Definition at line 50 of file classes.py.


The documentation for this class was generated from the following file: