pub struct BufferedProducer { /* private fields */ }Expand description
Opt-in producer for linger-based buffered sends.
This type owns an inner Producer and exposes lifecycle operations for
the buffered path.
Implementations§
Source§impl BufferedProducer
impl BufferedProducer
Sourcepub async fn send(&mut self, record: ProducerRecord) -> Result<ProducerDelivery>
pub async fn send(&mut self, record: ProducerRecord) -> Result<ProducerDelivery>
Enqueues one record for the buffered producer path.
The returned delivery handle resolves when the background task reaches a terminal result for this record.
Sourcepub async fn begin_transaction(&mut self) -> Result<()>
pub async fn begin_transaction(&mut self) -> Result<()>
Starts a transaction on a buffered producer configured with a transactional ID.
Sourcepub async fn send_group_offsets_to_transaction(
&mut self,
metadata: &ConsumerGroupMetadata,
assignments: &[ConsumerAssignment],
) -> Result<()>
pub async fn send_group_offsets_to_transaction( &mut self, metadata: &ConsumerGroupMetadata, assignments: &[ConsumerAssignment], ) -> Result<()>
Adds consumer group offsets to the active buffered transaction.
The command is ordered after all records accepted before this call. The records are guaranteed to be flushed before a later commit.
Sourcepub async fn commit_transaction(&mut self) -> Result<()>
pub async fn commit_transaction(&mut self) -> Result<()>
Flushes all accepted records and commits the active transaction.
A per-record Produce failure prevents EndTxn commit and leaves the transaction active so the caller can abort it.
Sourcepub async fn abort_transaction(&mut self) -> Result<()>
pub async fn abort_transaction(&mut self) -> Result<()>
Flushes accepted records and aborts the active transaction.
Sourcepub fn in_transaction(&self) -> bool
pub fn in_transaction(&self) -> bool
Returns whether this buffered producer currently has an active transaction.
Sourcepub fn transaction_status(&self) -> Option<TransactionStatus>
pub fn transaction_status(&self) -> Option<TransactionStatus>
Returns the buffered transactional producer lifecycle state.
None means this buffered producer is non-transactional. A Defunct
producer must be discarded after fencing or an unknown EndTxn outcome.
Sourcepub async fn flush(&mut self) -> Result<()>
pub async fn flush(&mut self) -> Result<()>
Flushes accepted buffered records.
Pending delivery handles are completed from the underlying batch Produce outcomes before this returns.