pub struct Producer<P = DefaultPartitioner> { /* private fields */ }
Expand description
The Kafka Producer
See module level documentation.
Implementations§
Source§impl Producer
impl Producer
Sourcepub fn from_client(client: KafkaClient) -> Builder<DefaultPartitioner>
pub fn from_client(client: KafkaClient) -> Builder<DefaultPartitioner>
Starts building a new producer using the given Kafka client.
Sourcepub fn from_hosts(hosts: Vec<String>) -> Builder<DefaultPartitioner>
pub fn from_hosts(hosts: Vec<String>) -> Builder<DefaultPartitioner>
Starts building a producer bootstraping internally a new kafka client from the given kafka hosts.
Sourcepub fn client(&self) -> &KafkaClient
pub fn client(&self) -> &KafkaClient
Borrows the underlying kafka client.
Sourcepub fn client_mut(&mut self) -> &mut KafkaClient
pub fn client_mut(&mut self) -> &mut KafkaClient
Borrows the underlying kafka client as mut.
Sourcepub fn into_client(self) -> KafkaClient
pub fn into_client(self) -> KafkaClient
Destroys this producer returning the underlying kafka client.
Source§impl<P: Partitioner> Producer<P>
impl<P: Partitioner> Producer<P>
Sourcepub fn send<'a, K, V>(&mut self, rec: &Record<'a, K, V>) -> Result<()>
pub fn send<'a, K, V>(&mut self, rec: &Record<'a, K, V>) -> Result<()>
Synchronously send the specified message to Kafka.
Sourcepub fn send_all<'a, K, V>(
&mut self,
recs: &[Record<'a, K, V>],
) -> Result<Vec<ProduceConfirm>>
pub fn send_all<'a, K, V>( &mut self, recs: &[Record<'a, K, V>], ) -> Result<Vec<ProduceConfirm>>
Synchronously send all of the specified messages to Kafka. To validate that all of the specified records have been successfully delivered, inspection of the offsets on the returned confirms is necessary.
Auto Trait Implementations§
impl<P> Freeze for Producer<P>where
P: Freeze,
impl<P> RefUnwindSafe for Producer<P>where
P: RefUnwindSafe,
impl<P> Send for Producer<P>where
P: Send,
impl<P> Sync for Producer<P>where
P: Sync,
impl<P> Unpin for Producer<P>where
P: Unpin,
impl<P> UnwindSafe for Producer<P>where
P: UnwindSafe,
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