madsim_rdkafka::producer::base_producer

Struct ThreadedProducer

Source
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,

Source

pub fn send<'a, K, P>( &self, record: BaseRecord<'a, K, P, C::DeliveryOpaque>, ) -> Result<(), (KafkaError, BaseRecord<'a, K, P, C::DeliveryOpaque>)>
where K: ToBytes + ?Sized, P: ToBytes + ?Sized,

Sends a message to Kafka.

See the documentation for BaseProducer::send for details.

Source

pub fn poll<T: Into<Timeout> + Send>(&self, timeout: T)

Polls the internal producer.

This is not normally required since the ThreadedProducer has a thread dedicated to calling poll regularly.

Trait Implementations§

Source§

impl<C, Part> Drop for ThreadedProducer<C, Part>
where Part: Partitioner, C: ProducerContext<Part> + 'static,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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,

Creates a client from a client configuration. The default client context will be used.
Source§

impl<C, Part> FromClientConfigAndContext<C> for ThreadedProducer<C, Part>
where Part: Partitioner + Send + Sync + 'static, C: ProducerContext<Part> + 'static,

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,

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,

Source§

fn client(&self) -> &Client<C>

Returns the Client underlying this producer.
Source§

fn flush<'life0, 'async_trait, T>( &'life0 self, timeout: T, ) -> Pin<Box<dyn Future<Output = KafkaResult<()>> + Send + 'async_trait>>
where T: 'async_trait + Into<Timeout> + Send, Self: 'async_trait, 'life0: 'async_trait,

Flushes any pending messages. Read more
Source§

fn purge(&self, flags: PurgeConfig)

Purge messages currently handled by the producer instance. Read more
Source§

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>>
where T: 'async_trait + Into<Timeout> + Send, Self: 'async_trait, 'life0: 'async_trait,

Enable sending transactions with this producer. Read more
Source§

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>>
where T: 'async_trait + Into<Timeout> + Send, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: '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>>
where T: 'async_trait + Into<Timeout> + Send, Self: 'async_trait, 'life0: '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>>
where T: 'async_trait + Into<Timeout> + Send, Self: 'async_trait, 'life0: 'async_trait,

Aborts the current transaction. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.