pub struct BaseConsumer<C = DefaultConsumerContext>{ }
Expand description
A low-level consumer that requires manual polling.
This consumer must be periodically polled to make progress on rebalancing, callbacks and to receive messages.
Source§ SourcePolls 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 events waiting to be handled. This is especially important for automatic consumer rebalance, as the rebalance function will be executed by the thread calling the poll() function.
§LifetimeThe returned message lives in the memory of the consumer and cannot outlive it.
SourceReturns 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.
§ExamplesAll these are equivalent and will receive messages without timing out.
loop {
let message = consumer.poll(None);
}
for message in consumer.iter() {
}
for message in &consumer {
}
Source
Splits messages for the specified partition into their own queue.
If the topic
or partition
is invalid, returns None
.
After calling this method, newly-fetched messages for the specified partition will be returned via PartitionQueue::poll
rather than BaseConsumer::poll
. Note that there may be buffered messages for the specified partition that will continue to be returned by BaseConsumer::poll
. For best results, call split_partition_queue
before the first call to BaseConsumer::poll
.
You must continue to call BaseConsumer::poll
, even if no messages are expected, to serve callbacks.
Note that calling Consumer::assign
will deactivate any existing partition queues. You will need to call this method for every partition that should be split after every call to assign
.
Beware that this method is implemented for &Arc<Self>
, not &self
. You will need to wrap your consumer in an Arc
in order to call this method. This design permits moving the partition queue to another thread while ensuring the partition queue does not outlive the consumer.
Close the queue used by a consumer. Only exposed for advanced usage of this API and should not be used under normal circumstances.
SourceReturns true if the consumer is closed, else false.
SourceSets a callback that will be invoked whenever the queue becomes nonempty.
Source§ Source§Returns the
Client
underlying this consumer.
Source§Returns the current consumer group metadata associated with the consumer.
Read more Source§Subscribes the consumer to a list of topics.
Source§Unsubscribes the current subscription list.
Source§Manually assigns topics and partitions to the consumer. If used, automatic consumer rebalance won’t be activated.
Source§Clears all topic and partitions currently assigned to the consumer
Source§Incrementally add partitions from the current assignment
Source§Incrementally remove partitions from the current assignment
Source§Seeks to offset
for the specified topic
and partition
. After a successful call to seek
, the next poll of the consumer will return the message with offset
.
Seeks consumer for partitions in topic_partition_list
to the per-partition offset in the offset
field of TopicPartitionListElem
. The offset can be either absolute (>= 0) or a logical offset. Seek should only be performed on already assigned/consumed partitions. Individual partition errors are reported in the per-partition error
field of TopicPartitionListElem
.
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 Source§Commits 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.
Source§Commit the provided message. Note that this will also automatically commit every message with lower offset within the same partition.
Read more Source§Stores offset to be used on the next (auto)commit. When using this enable.auto.offset.store
should be set to false
in the config.
Store offsets to be used on the next (auto)commit. When using this enable.auto.offset.store
should be set to false
in the config.
Returns the current topic subscription.
Source§Returns the current partition assignment.
Source§Check whether the consumer considers the current assignment to have been lost involuntarily.
Read more Source§Retrieves the committed offsets for topics and partitions.
Source§Retrieves the committed offsets for specified topics and partitions.
Source§Looks up the offsets for this consumer’s partitions by timestamp.
Source§Looks up the offsets for the specified partitions by timestamp.
Source§Retrieve current positions (offsets) for topics and partitions.
Source§Returns the metadata information for the specified topic, or for all topics in the cluster if no topic is specified.
Source§Returns the low and high watermarks for a specific topic and partition.
Source§Returns the group membership information for the given group. If no group is specified, all groups will be returned.
Source§Pauses consumption for the provided list of partitions.
Source§Resumes consumption for the provided list of partitions.
Source§Reports the rebalance protocol in use.
Source§ Source§ Source§ Source§Creates a client from a client configuration. The default client context will be used.
Source§Creates a new BaseConsumer
starting from a ClientConfig
.
Creates a client from a client configuration and a client context.
Source§ Source§The type of the elements being iterated over.
Source§Which kind of iterator are we turning this into?
Source§RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4