pub struct Consumer { /* private fields */ }Expand description
Direct Kafka consumer for manually assigned topic partitions.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn assign(&mut self, topic: impl Into<String>, partition: i32, offset: i64)
pub fn assign(&mut self, topic: impl Into<String>, partition: i32, offset: i64)
Assigns a topic partition and next offset to fetch.
Sourcepub fn assignments(&self) -> &[ConsumerAssignment]
pub fn assignments(&self) -> &[ConsumerAssignment]
Returns the current topic partition assignments.
Sourcepub fn split_partition_queue(
&mut self,
topic: impl Into<String>,
partition: i32,
) -> Result<ConsumerPartitionQueue>
pub fn split_partition_queue( &mut self, topic: impl Into<String>, partition: i32, ) -> Result<ConsumerPartitionQueue>
Splits one assigned topic partition into a bounded receive queue.
Records fetched for the partition are delivered to the returned queue
instead of the vector returned by Self::poll. The queue capacity is
configured with ConsumerConfig::partition_queue_capacity. When the
queue is full, poll returns an error and does not advance beyond the
last record accepted by the queue.
Sourcepub fn position(&self, topic: &str, partition: i32) -> Option<i64>
pub fn position(&self, topic: &str, partition: i32) -> Option<i64>
Returns the next offset for an assigned topic partition.
Sourcepub fn seek(&mut self, topic: &str, partition: i32, offset: i64) -> Result<()>
pub fn seek(&mut self, topic: &str, partition: i32, offset: i64) -> Result<()>
Changes the next offset for an assigned topic partition.
Sourcepub fn pause(&mut self, topic: &str, partition: i32) -> Result<()>
pub fn pause(&mut self, topic: &str, partition: i32) -> Result<()>
Pauses fetching from an assigned topic partition.
Sourcepub fn resume(&mut self, topic: &str, partition: i32) -> Result<()>
pub fn resume(&mut self, topic: &str, partition: i32) -> Result<()>
Resumes fetching from an assigned topic partition.
Sourcepub async fn fetch_watermarks(
&mut self,
topic: impl Into<String>,
partition: i32,
) -> Result<PartitionWatermarks>
pub async fn fetch_watermarks( &mut self, topic: impl Into<String>, partition: i32, ) -> Result<PartitionWatermarks>
Fetches the earliest and latest available offsets for a topic partition.
The partition does not need to be assigned to this consumer. Kafka’s latest offset is the next offset after the current log end.
Sourcepub async fn offset_for_leader_epoch(
&mut self,
topic: impl Into<String>,
partition: i32,
current_leader_epoch: i32,
leader_epoch: i32,
) -> Result<LeaderEpochOffset>
pub async fn offset_for_leader_epoch( &mut self, topic: impl Into<String>, partition: i32, current_leader_epoch: i32, leader_epoch: i32, ) -> Result<LeaderEpochOffset>
Resolves the end offset for a partition leader epoch.
current_leader_epoch is the epoch from the consumer’s current
metadata, or -1 when it is unknown. leader_epoch is the epoch whose
end offset should be returned. The partition does not need to be
assigned to this consumer.
Sourcepub async fn poll(&mut self) -> Result<Vec<ConsumerRecord>>
pub async fn poll(&mut self) -> Result<Vec<ConsumerRecord>>
Polls assigned partitions and advances in-memory offsets for fetched records.