pub struct ThreadedProducer<C, Part: Partitioner = NoCustomPartitioner>where
C: ProducerContext<Part> + 'static,{ /* private fields */ }
Expand description
A low-level Kafka producer with a separate thread for event handling.
The ThreadedProducer
is a BaseProducer
with a separate thread
dedicated to calling poll
at regular intervals in order to execute any
queued events, such as delivery notifications. The thread will be
automatically stopped when the producer is dropped.
Implementations§
Source§impl<C, Part> ThreadedProducer<C, Part>where
Part: Partitioner,
C: ProducerContext<Part> + 'static,
impl<C, Part> ThreadedProducer<C, Part>where
Part: Partitioner,
C: ProducerContext<Part> + 'static,
Sourcepub fn send<'a, K, P>(
&self,
record: BaseRecord<'a, K, P, C::DeliveryOpaque>,
) -> Result<(), (KafkaError, BaseRecord<'a, K, P, C::DeliveryOpaque>)>
pub fn send<'a, K, P>( &self, record: BaseRecord<'a, K, P, C::DeliveryOpaque>, ) -> Result<(), (KafkaError, BaseRecord<'a, K, P, C::DeliveryOpaque>)>
Sends a message to Kafka.
See the documentation for BaseProducer::send
for details.
Trait Implementations§
Source§impl<C, Part> Drop for ThreadedProducer<C, Part>where
Part: Partitioner,
C: ProducerContext<Part> + 'static,
impl<C, Part> Drop for ThreadedProducer<C, Part>where
Part: Partitioner,
C: ProducerContext<Part> + 'static,
Source§impl FromClientConfig for ThreadedProducer<DefaultProducerContext, NoCustomPartitioner>
impl FromClientConfig for ThreadedProducer<DefaultProducerContext, NoCustomPartitioner>
Source§fn from_config<'life0, 'async_trait>(
config: &'life0 ClientConfig,
) -> Pin<Box<dyn Future<Output = KafkaResult<ThreadedProducer<DefaultProducerContext>>> + Send + 'async_trait>>where
'life0: 'async_trait,
fn from_config<'life0, 'async_trait>(
config: &'life0 ClientConfig,
) -> Pin<Box<dyn Future<Output = KafkaResult<ThreadedProducer<DefaultProducerContext>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Creates a client from a client configuration. The default client context
will be used.
Source§impl<C, Part> FromClientConfigAndContext<C> for ThreadedProducer<C, Part>
impl<C, Part> FromClientConfigAndContext<C> for ThreadedProducer<C, Part>
Source§fn from_config_and_context<'life0, 'async_trait>(
config: &'life0 ClientConfig,
context: C,
) -> Pin<Box<dyn Future<Output = KafkaResult<ThreadedProducer<C, Part>>> + Send + 'async_trait>>where
'life0: 'async_trait,
fn from_config_and_context<'life0, 'async_trait>(
config: &'life0 ClientConfig,
context: C,
) -> Pin<Box<dyn Future<Output = KafkaResult<ThreadedProducer<C, Part>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Creates a client from a client configuration and a client context.
Source§impl<C, Part> Producer<C, Part> for ThreadedProducer<C, Part>where
Part: Partitioner,
C: ProducerContext<Part> + 'static,
impl<C, Part> Producer<C, Part> for ThreadedProducer<C, Part>where
Part: Partitioner,
C: ProducerContext<Part> + 'static,
Source§fn flush<'life0, 'async_trait, T>(
&'life0 self,
timeout: T,
) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
fn flush<'life0, 'async_trait, T>( &'life0 self, timeout: T, ) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
Flushes any pending messages. Read more
Source§fn purge(&self, flags: PurgeConfig)
fn purge(&self, flags: PurgeConfig)
Purge messages currently handled by the producer instance. Read more
Source§fn in_flight_count(&self) -> i32
fn in_flight_count(&self) -> i32
Returns the number of messages that are either waiting to be sent or are
sent but are waiting to be acknowledged.
Source§fn init_transactions<'life0, 'async_trait, T>(
&'life0 self,
timeout: T,
) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
fn init_transactions<'life0, 'async_trait, T>( &'life0 self, timeout: T, ) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
Enable sending transactions with this producer. Read more
Source§fn begin_transaction(&self) -> KafkaResult<()>
fn begin_transaction(&self) -> KafkaResult<()>
Begins a new transaction. Read more
Source§fn send_offsets_to_transaction<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
offsets: &'life1 TopicPartitionList,
cgm: &'life2 ConsumerGroupMetadata,
timeout: T,
) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
fn send_offsets_to_transaction<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, offsets: &'life1 TopicPartitionList, cgm: &'life2 ConsumerGroupMetadata, timeout: T, ) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
Associates an offset commit operation with this transaction. Read more
Source§fn commit_transaction<'life0, 'async_trait, T>(
&'life0 self,
timeout: T,
) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
fn commit_transaction<'life0, 'async_trait, T>( &'life0 self, timeout: T, ) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
Commits the current transaction. Read more
Source§fn abort_transaction<'life0, 'async_trait, T>(
&'life0 self,
timeout: T,
) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
fn abort_transaction<'life0, 'async_trait, T>( &'life0 self, timeout: T, ) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
Aborts the current transaction. Read more
Source§fn context(&self) -> &Arc<C>
fn context(&self) -> &Arc<C>
Returns a reference to the
ProducerContext
used to create this
producer.Auto Trait Implementations§
impl<C, Part> Freeze for ThreadedProducer<C, Part>
impl<C, Part = NoCustomPartitioner> !RefUnwindSafe for ThreadedProducer<C, Part>
impl<C, Part> Send for ThreadedProducer<C, Part>
impl<C, Part> Sync for ThreadedProducer<C, Part>
impl<C, Part> Unpin for ThreadedProducer<C, Part>
impl<C, Part = NoCustomPartitioner> !UnwindSafe for ThreadedProducer<C, Part>
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