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(
&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
Trait Implementations§
source§impl Clone for TopicProducer
impl Clone for TopicProducer
source§fn clone(&self) -> TopicProducer
fn clone(&self) -> TopicProducer
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more