faust.transport.producer

Producer.

The Producer is responsible for:

  • Holds reference to the transport that created it

  • … and the app via self.transport.app.

  • Sending messages.

class faust.transport.producer.Producer(transport: faust.types.transports.TransportT, loop: asyncio.events.AbstractEventLoop = None, **kwargs: Any) → None[source]

Base Producer.

async on_start() → None[source]

Service is starting.

Return type

None

async send(topic: str, key: Optional[bytes], value: Optional[bytes], partition: Optional[int], timestamp: Optional[float], headers: Union[List[Tuple[str, bytes]], Mapping[str, bytes], None], *, transactional_id: str = None) → Awaitable[faust.types.tuples.RecordMetadata][source]

Schedule message to be sent by producer.

Return type

Awaitable[RecordMetadata]

send_soon(fut: faust.types.tuples.FutureMessage) → None[source]
Return type

None

async send_and_wait(topic: str, key: Optional[bytes], value: Optional[bytes], partition: Optional[int], timestamp: Optional[float], headers: Union[List[Tuple[str, bytes]], Mapping[str, bytes], None], *, transactional_id: str = None) → faust.types.tuples.RecordMetadata[source]

Send message and wait for it to be transmitted.

Return type

RecordMetadata

async flush() → None[source]

Flush all in-flight messages.

Return type

None

async create_topic(topic: str, partitions: int, replication: int, *, config: Mapping[str, Any] = None, timeout: Union[datetime.timedelta, float, str] = 1000.0, retention: Union[datetime.timedelta, float, str] = None, compacting: bool = None, deleting: bool = None, ensure_created: bool = False) → None[source]

Create/declare topic on server.

Return type

None

key_partition(topic: str, key: bytes) → faust.types.tuples.TP[source]

Hash key to determine partition.

Return type

TP

async begin_transaction(transactional_id: str) → None[source]

Begin transaction by id.

Return type

None

async commit_transaction(transactional_id: str) → None[source]

Commit transaction by id.

Return type

None

async abort_transaction(transactional_id: str) → None[source]

Abort and rollback transaction by id.

Return type

None

async stop_transaction(transactional_id: str) → None[source]

Stop transaction by id.

Return type

None

async maybe_begin_transaction(transactional_id: str) → None[source]

Begin transaction by id, if not already started.

Return type

None

async commit_transactions(tid_to_offset_map: Mapping[str, Mapping[faust.types.tuples.TP, int]], group_id: str, start_new_transaction: bool = True) → None[source]

Commit transactions.

Return type

None

logger = <Logger faust.transport.producer (WARNING)>
supports_headers() → bool[source]

Return True if headers are supported by this transport.

Return type

bool