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

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.

Methods

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

[src]

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.

Lifetime

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

Important traits for Iter<'a, 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.

Examples

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 FromClientConfig for BaseConsumer
[src]

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

Creates a new BaseConsumer starting from a ClientConfig.

[src]

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

[src]

Returns a reference to the BaseConsumer.

[src]

Subscribe the consumer to a list of topics.

[src]

[src]

Manually assign topics and partitions to the consumer. If used, automatic consumer rebalance won't be activated. Read more

[src]

Commits the offset of the specified message. The commit can be sync (blocking), or async. Notice that when a specific offset is committed, all the previous offsets are considered committed as well. Use this method only if you are processing messages in order. Read more

[src]

Commit the current consumer state. Notice that if the consumer fails after a message has been received, but before the message has been processed by the user code, this might lead to data loss. Check the "at-least-once delivery" section in the readme for more information. Read more

[src]

[src]

Store offset for this message to be used on the next (auto)commit. When using this enable.auto.offset.store should be set to false in the config. Read more

[src]

Returns the current topic subscription.

[src]

Returns the current partition assignment.

[src]

Retrieve committed offsets for topics and partitions.

[src]

Lookup the offsets for this consumer's partitions by timestamp.

[src]

Retrieve current positions (offsets) for topics and partitions.

[src]

Returns the metadata information for the specified topic, or for all topics in the cluster if no topic is specified. Read more

[src]

Returns the metadata information for all the topics in the cluster.

[src]

Returns the group membership information for the given group. If no group is specified, all groups will be returned. Read more

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

[src]

Executes the destructor for this type. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

Auto Trait Implementations

impl<C> Send for BaseConsumer<C>

impl<C> Sync for BaseConsumer<C>