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
sourceimpl TopicProducer
impl TopicProducer
sourcepub async fn flush(&self) -> Result<(), FluvioError>
pub async fn flush(&self) -> Result<(), FluvioError>
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, FluvioError> where
K: Into<RecordKey>,
V: Into<RecordData>,
pub async fn send<K, V>(
&self,
key: K,
value: V
) -> Result<ProduceOutput, FluvioError> 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.
Example
producer.send("Key", "Value").await?;
pub async fn send_all<K, V, I>(
&self,
records: I
) -> Result<Vec<ProduceOutput>, FluvioError> 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.
Auto Trait Implementations
impl !RefUnwindSafe for TopicProducer
impl Send for TopicProducer
impl Sync for TopicProducer
impl Unpin for TopicProducer
impl !UnwindSafe for TopicProducer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more