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]
pub fn send_copy<P: ?Sized, K: ?Sized>(
&self,
topic: &str,
partition: Option<i32>,
payload: Option<&P>,
key: Option<&K>,
timestamp: Option<i64>,
delivery_opaque: C::DeliveryOpaque
) -> KafkaResult<()> where
K: ToBytes,
P: ToBytes,
[src]
&self,
topic: &str,
partition: Option<i32>,
payload: Option<&P>,
key: Option<&K>,
timestamp: Option<i64>,
delivery_opaque: C::DeliveryOpaque
) -> KafkaResult<()> 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]
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]
Flushes the producer. Should be called before termination.
pub fn in_flight_count(&self) -> i32
[src]
Returns the number of messages waiting to be sent, or send but not acknowledged yet.
Trait Implementations
impl FromClientConfig for ThreadedProducer<DefaultProducerContext>
[src]
fn from_config(
config: &ClientConfig
) -> KafkaResult<ThreadedProducer<DefaultProducerContext>>
[src]
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]
fn from_config_and_context(
config: &ClientConfig,
context: C
) -> KafkaResult<ThreadedProducer<C>>
[src]
config: &ClientConfig,
context: C
) -> KafkaResult<ThreadedProducer<C>>
Create a client from client configuration and a client context.