[][src]Struct rdkafka::consumer::base_consumer::BaseConsumer

pub struct BaseConsumer<C: ConsumerContext = DefaultConsumerContext> { /* fields omitted */ }

Low level wrapper around the librdkafka consumer. This consumer requires to be periodically polled to make progress on rebalance, callbacks and to receive messages.


impl<C: ConsumerContext> BaseConsumer<C>[src]

pub fn context(&self) -> &C[src]

Returns the context used to create this consumer.

pub fn poll<T: Into<Timeout>>(
    timeout: T
) -> Option<KafkaResult<BorrowedMessage>>

Polls the consumer for new messages.

It won't block for more than the specified timeout. Use zero Duration for non-blocking call. With no timeout it blocks until an event is received.

This method should be called at regular intervals, even if no message is expected, to serve any queued callbacks waiting to be called. This is especially important for automatic consumer rebalance, as the rebalance function will be executed by the thread calling the poll() function.


The returned message lives in the memory of the consumer and cannot outlive it.

Important traits for Iter<'a, C>
pub fn iter(&self) -> Iter<C>[src]

Returns an iterator over the available messages.

It repeatedly calls poll with no timeout.

Note that it's also possible to iterate over the consumer directly.


All these are equivalent and will receive messages without timing out.

loop {
  let message = consumer.poll(None);
  // Handle the message
for message in consumer.iter() {
  // Handle the message
for message in &consumer {
  // Handle the message

Trait Implementations

impl<C: ConsumerContext> Consumer<C> for BaseConsumer<C>[src]

fn offsets_for_times<T: Into<Timeout>>(
    timestamps: TopicPartitionList,
    timeout: T
) -> KafkaResult<TopicPartitionList>

timestamps is a TopicPartitionList with timestamps instead of offsets.

impl<C: ConsumerContext> Drop for BaseConsumer<C>[src]

impl FromClientConfig for BaseConsumer[src]

impl<C: ConsumerContext> FromClientConfigAndContext<C> for BaseConsumer<C>[src]

Creates a new BaseConsumer starting from a ClientConfig.

impl<'a, C: ConsumerContext + 'a> IntoIterator for &'a BaseConsumer<C>[src]

type Item = KafkaResult<BorrowedMessage<'a>>

The type of the elements being iterated over.

type IntoIter = Iter<'a, C>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<C> RefUnwindSafe for BaseConsumer<C> where
    C: RefUnwindSafe

impl<C> Send for BaseConsumer<C>

impl<C> Sync for BaseConsumer<C>

impl<C> Unpin for BaseConsumer<C>

impl<C> UnwindSafe for BaseConsumer<C> where
    C: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.