Struct fluvio::TopicProducer
source · pub struct TopicProducer { /* 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 TopicProducer
impl TopicProducer
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<K, V>(&self, key: K, value: V) -> Result<ProduceOutput>where
K: Into<RecordKey>,
V: Into<RecordData>,
pub async fn send<K, V>(&self, key: K, value: V) -> Result<ProduceOutput>where K: Into<RecordKey>, V: Into<RecordData>,
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<K, V, I>(&self, records: I) -> Result<Vec<ProduceOutput>>where K: Into<RecordKey>, V: Into<RecordData>, I: IntoIterator<Item = (K, V)>,
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