pub struct TopicProducer<S>{ /* private fields */ }Expand description
An interface for producing events to a particular topic
A TopicProducer allows you to send events to the specific
topic it was initialized for. Once you have a TopicProducer,
you can send events to the topic, choosing which partition /// each event should be delivered to.
Implementations§
Source§impl<S> TopicProducer<S>
impl<S> TopicProducer<S>
pub fn topic(&self) -> &str
pub fn config(&self) -> &TopicProducerConfig
Sourcepub async fn flush(&self) -> Result<()>
pub async fn flush(&self) -> Result<()>
Send all the queued records in the producer batches.
§Example
producer.send("Key", "Value").await?;
producer.flush().await?;Sourcepub async fn send(
&self,
key: impl Into<RecordKey>,
value: impl Into<RecordData>,
) -> Result<ProduceOutput>
pub async fn send( &self, key: impl Into<RecordKey>, value: impl Into<RecordData>, ) -> Result<ProduceOutput>
Sends a key/value record to this producer’s Topic.
The partition that the record will be sent to is derived from the Key.
Depending on the producer configuration, a send call will not send immediately
the record to the SPU. Instead, it could add the record to a batch.
TopicProducer::flush is used to immediately send all the queued records in the producer batches.
If the batch queue is full, a send call will block until there will be enough space for new batch.
§Example
producer.send("Key", "Value").await?;pub async fn send_all( &self, records: impl IntoIterator<Item = (impl Into<RecordKey>, impl Into<RecordData>)>, ) -> Result<Vec<ProduceOutput>>
Sourcepub async fn clear_errors(&self)
pub async fn clear_errors(&self)
Clear partition producers errors in order to make partition producers available. This is needed once an error is present in order to send new records again.
Sourcepub fn metrics(&self) -> Arc<ClientMetrics>
pub fn metrics(&self) -> Arc<ClientMetrics>
Return a shared instance of ClientMetrics