pub struct KafkaProducer { /* private fields */ }Expand description
Produces inventory records onto a Kafka topic.
Sends are non-blocking: records go onto librdkafka’s internal queue and a background
thread delivers them. When that queue is full, Producer::send returns an error
rather than waiting.
Implementations§
Source§impl KafkaProducer
impl KafkaProducer
Sourcepub fn try_new(
config: KafkaConfig,
on_delivery_failure: Option<OnDeliveryFailure>,
) -> Result<Self, KafkaProducerError>
pub fn try_new( config: KafkaConfig, on_delivery_failure: Option<OnDeliveryFailure>, ) -> Result<Self, KafkaProducerError>
Creates a producer from config, optionally reporting delivery failures to
on_delivery_failure.
Failures are always logged. The callback is how a caller additionally counts them without this crate having to depend on a metrics backend.
Trait Implementations§
Source§impl Debug for KafkaProducer
impl Debug for KafkaProducer
Source§impl Producer for KafkaProducer
impl Producer for KafkaProducer
Source§type Error = KafkaProducerError
type Error = KafkaProducerError
What can go wrong when sending.
Source§fn send(&self, key: &[u8], payload: Vec<u8>) -> Result<(), Self::Error>
fn send(&self, key: &[u8], payload: Vec<u8>) -> Result<(), Self::Error>
Enqueues one record. Read more
Source§fn join_blocking(&self, timeout: Duration) -> Result<(), Self::Error>
fn join_blocking(&self, timeout: Duration) -> Result<(), Self::Error>
Blocks until enqueued records have been delivered, or
timeout elapses. Read moreErases this producer’s transport and error type, so one producer can serve
several trackers. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for KafkaProducer
impl !UnwindSafe for KafkaProducer
impl Freeze for KafkaProducer
impl Send for KafkaProducer
impl Sync for KafkaProducer
impl Unpin for KafkaProducer
impl UnsafeUnpin for KafkaProducer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more