Struct rdkafka::producer::base_producer::ThreadedProducer [−][src]
#[must_use = "The threaded producer will stop immediately if unused"]pub struct ThreadedProducer<C: ProducerContext + 'static> { /* fields omitted */ }
A 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 event, such as delivery notifications. The
thread will be automatically stopped when the producer is dropped.
Methods
impl<C: ProducerContext + 'static> ThreadedProducer<C>
[src]
impl<C: ProducerContext + 'static> ThreadedProducer<C>
pub fn send<'a, K: ?Sized, P: ?Sized>(
&self,
record: BaseRecord<'a, K, P, C::DeliveryOpaque>
) -> Result<(), (KafkaError, BaseRecord<'a, K, P, C::DeliveryOpaque>)> where
K: ToBytes,
P: ToBytes,
[src]
pub fn send<'a, K: ?Sized, P: ?Sized>(
&self,
record: BaseRecord<'a, K, P, C::DeliveryOpaque>
) -> Result<(), (KafkaError, BaseRecord<'a, K, P, C::DeliveryOpaque>)> where
K: ToBytes,
P: ToBytes,
Sends a message to Kafka. See the documentation in BaseProducer
.
pub fn poll<T: Into<Option<Duration>>>(&self, timeout: T)
[src]
pub fn poll<T: Into<Option<Duration>>>(&self, timeout: T)
Polls the internal producer. This is not normally required since the ThreadedProducer
had
a thread dedicated to calling poll
regularly.
pub fn flush<T: Into<Option<Duration>>>(&self, timeout: T)
[src]
pub fn flush<T: Into<Option<Duration>>>(&self, timeout: T)
Flushes the producer. Should be called before termination.
pub fn in_flight_count(&self) -> i32
[src]
pub fn in_flight_count(&self) -> i32
Returns the number of messages waiting to be sent, or send but not acknowledged yet.
Trait Implementations
impl FromClientConfig for ThreadedProducer<DefaultProducerContext>
[src]
impl FromClientConfig for ThreadedProducer<DefaultProducerContext>
fn from_config(
config: &ClientConfig
) -> KafkaResult<ThreadedProducer<DefaultProducerContext>>
[src]
fn from_config(
config: &ClientConfig
) -> KafkaResult<ThreadedProducer<DefaultProducerContext>>
Create a client from client configuration. The default client context will be used.
impl<C: ProducerContext + 'static> FromClientConfigAndContext<C> for ThreadedProducer<C>
[src]
impl<C: ProducerContext + 'static> FromClientConfigAndContext<C> for ThreadedProducer<C>
fn from_config_and_context(
config: &ClientConfig,
context: C
) -> KafkaResult<ThreadedProducer<C>>
[src]
fn from_config_and_context(
config: &ClientConfig,
context: C
) -> KafkaResult<ThreadedProducer<C>>
Create a client from client configuration and a client context.
impl<C: ProducerContext + 'static> Drop for ThreadedProducer<C>
[src]
impl<C: ProducerContext + 'static> Drop for ThreadedProducer<C>
Auto Trait Implementations
impl<C> Send for ThreadedProducer<C>
impl<C> Send for ThreadedProducer<C>
impl<C> Sync for ThreadedProducer<C>
impl<C> Sync for ThreadedProducer<C>