pub trait DynConsumer<K, V>:
Sealed<K, V>
+ Send
+ 'static{
Show 46 methods
// Required methods
fn assignment(&mut self) -> HashSet<TopicPartition>;
fn subscription(&mut self) -> HashSet<String>;
fn paused(&mut self) -> HashSet<TopicPartition>;
fn group_metadata(&mut self) -> Arc<dyn ConsumerGroupMetadata>;
fn current_lag<'a>(
&'a mut self,
topic_partition: &'a TopicPartition,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>, Error>> + Send + 'a>>;
fn metrics(&self) -> MetricsView;
fn subscribe_with_topics<'a>(
&'a mut self,
topics: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn subscribe_with_topics_listener<'a>(
&'a mut self,
topics: Vec<String>,
listener: Arc<dyn ConsumerRebalanceListener>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn subscribe_with_pattern<'a>(
&'a mut self,
pattern: SubscriptionPattern,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn subscribe_with_pattern_listener<'a>(
&'a mut self,
pattern: SubscriptionPattern,
listener: Arc<dyn ConsumerRebalanceListener>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn assign<'a>(
&'a mut self,
partitions: Vec<TopicPartition>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn unsubscribe<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn poll<'a>(
&'a mut self,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<ConsumerRecords<K, V>, Error>> + Send + 'a>>;
fn commit_sync<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn commit_sync_with_timeout<'a>(
&'a mut self,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn commit_sync_with_offsets<'a>(
&'a mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn commit_sync_with_offsets_timeout<'a>(
&'a mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn commit_async<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn commit_async_with_callback<'a>(
&'a mut self,
callback: Arc<dyn OffsetCommitCallback>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn commit_async_with_offsets_callback<'a>(
&'a mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
callback: Arc<dyn OffsetCommitCallback>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn seek_with_offset<'a>(
&'a mut self,
partition: TopicPartition,
offset: i64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn seek_with_offset_and_metadata<'a>(
&'a mut self,
partition: TopicPartition,
offset_and_metadata: OffsetAndMetadata,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn seek_to_beginning<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn seek_to_end<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn position<'a>(
&'a mut self,
partition: &'a TopicPartition,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'a>>;
fn position_with_timeout<'a>(
&'a mut self,
partition: &'a TopicPartition,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'a>>;
fn committed<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>> + Send + 'a>>;
fn committed_with_timeout<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>> + Send + 'a>>;
fn partitions_for<'a>(
&'a mut self,
topic: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<PartitionInfo>, Error>> + Send + 'a>>;
fn partitions_for_with_timeout<'a>(
&'a mut self,
topic: &'a str,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<PartitionInfo>, Error>> + Send + 'a>>;
fn list_topics<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send + 'a>>;
fn list_topics_with_timeout<'a>(
&'a mut self,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send + 'a>>;
fn offsets_for_times<'a>(
&'a mut self,
timestamps_to_search: HashMap<TopicPartition, i64>,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send + 'a>>;
fn offsets_for_times_with_timeout<'a>(
&'a mut self,
timestamps_to_search: HashMap<TopicPartition, i64>,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send + 'a>>;
fn beginning_offsets<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>;
fn beginning_offsets_with_timeout<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>;
fn end_offsets<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>;
fn end_offsets_with_timeout<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>;
fn pause<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn resume<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn enforce_rebalance<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn enforce_rebalance_with_reason<'a>(
&'a mut self,
reason: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn close<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn close_with_options<'a>(
&'a mut self,
options: CloseOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
fn wakeup(&self);
fn handle(&self) -> ConsumerHandle;
}Expand description
A dyn-compatible Consumer, for holding different consumer
implementations behind one type, e.g. Box<dyn DynConsumer<K, V>>.
Every Consumer implements DynConsumer automatically, and the trait is
sealed, so it cannot be implemented directly: implement Consumer
instead. Each method forwards to the Consumer method of the same name;
asynchronous methods return the future boxed, which costs one allocation per
call. dyn DynConsumer<K, V> implements Consumer in turn, so a boxed
consumer can be passed as &mut *boxed to generic code taking
C: Consumer<K, V> + ?Sized, and its methods can be called with only
Consumer in scope.
With both traits in scope a method call on a concrete consumer (a
KafkaConsumer or MockConsumer) is ambiguous, since both apply to it;
call it as Consumer::poll(&mut consumer, timeout), or import only one of
the two traits. A call on a dyn DynConsumer resolves to DynConsumer’s
own method either way.
use confluent_kafka::consumer::{DynConsumer, MockConsumer};
let consumers: Vec<Box<dyn DynConsumer<String, String>>> = vec![
Box::new(MockConsumer::<String, String>::new("earliest").unwrap()),
Box::new(MockConsumer::<String, String>::new("latest").unwrap()),
];
assert_eq!(2, consumers.len());Required Methods§
Sourcefn assignment(&mut self) -> HashSet<TopicPartition>
fn assignment(&mut self) -> HashSet<TopicPartition>
Sourcefn subscription(&mut self) -> HashSet<String>
fn subscription(&mut self) -> HashSet<String>
Sourcefn paused(&mut self) -> HashSet<TopicPartition>
fn paused(&mut self) -> HashSet<TopicPartition>
Sourcefn group_metadata(&mut self) -> Arc<dyn ConsumerGroupMetadata>
fn group_metadata(&mut self) -> Arc<dyn ConsumerGroupMetadata>
Sourcefn current_lag<'a>(
&'a mut self,
topic_partition: &'a TopicPartition,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>, Error>> + Send + 'a>>
fn current_lag<'a>( &'a mut self, topic_partition: &'a TopicPartition, ) -> Pin<Box<dyn Future<Output = Result<Option<i64>, Error>> + Send + 'a>>
Sourcefn metrics(&self) -> MetricsView
fn metrics(&self) -> MetricsView
Sourcefn subscribe_with_topics<'a>(
&'a mut self,
topics: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn subscribe_with_topics<'a>( &'a mut self, topics: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::subscribe_with_topics.
§Arguments
topics- asConsumer::subscribe_with_topics.
§Errors
Sourcefn subscribe_with_topics_listener<'a>(
&'a mut self,
topics: Vec<String>,
listener: Arc<dyn ConsumerRebalanceListener>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn subscribe_with_topics_listener<'a>( &'a mut self, topics: Vec<String>, listener: Arc<dyn ConsumerRebalanceListener>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::subscribe_with_topics_listener.
§Arguments
topics- asConsumer::subscribe_with_topics_listener.listener- asConsumer::subscribe_with_topics_listener.
§Errors
Sourcefn subscribe_with_pattern<'a>(
&'a mut self,
pattern: SubscriptionPattern,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn subscribe_with_pattern<'a>( &'a mut self, pattern: SubscriptionPattern, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::subscribe_with_pattern.
§Arguments
pattern- asConsumer::subscribe_with_pattern.
§Errors
Sourcefn subscribe_with_pattern_listener<'a>(
&'a mut self,
pattern: SubscriptionPattern,
listener: Arc<dyn ConsumerRebalanceListener>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn subscribe_with_pattern_listener<'a>( &'a mut self, pattern: SubscriptionPattern, listener: Arc<dyn ConsumerRebalanceListener>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::subscribe_with_pattern_listener.
§Arguments
pattern- asConsumer::subscribe_with_pattern_listener.listener- asConsumer::subscribe_with_pattern_listener.
§Errors
Sourcefn assign<'a>(
&'a mut self,
partitions: Vec<TopicPartition>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn assign<'a>( &'a mut self, partitions: Vec<TopicPartition>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn unsubscribe<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn unsubscribe<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn poll<'a>(
&'a mut self,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<ConsumerRecords<K, V>, Error>> + Send + 'a>>
fn poll<'a>( &'a mut self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<ConsumerRecords<K, V>, Error>> + Send + 'a>>
See Consumer::poll.
§Arguments
timeout- asConsumer::poll.
§Returns
As Consumer::poll.
§Errors
As Consumer::poll.
Sourcefn commit_sync<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn commit_sync<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn commit_sync_with_timeout<'a>(
&'a mut self,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn commit_sync_with_timeout<'a>( &'a mut self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::commit_sync_with_timeout.
§Arguments
timeout- asConsumer::commit_sync_with_timeout.
§Errors
Sourcefn commit_sync_with_offsets<'a>(
&'a mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn commit_sync_with_offsets<'a>( &'a mut self, offsets: HashMap<TopicPartition, OffsetAndMetadata>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::commit_sync_with_offsets.
§Arguments
offsets- asConsumer::commit_sync_with_offsets.
§Errors
Sourcefn commit_sync_with_offsets_timeout<'a>(
&'a mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn commit_sync_with_offsets_timeout<'a>( &'a mut self, offsets: HashMap<TopicPartition, OffsetAndMetadata>, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::commit_sync_with_offsets_timeout.
§Arguments
offsets- asConsumer::commit_sync_with_offsets_timeout.timeout- asConsumer::commit_sync_with_offsets_timeout.
§Errors
Sourcefn commit_async<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn commit_async<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn commit_async_with_callback<'a>(
&'a mut self,
callback: Arc<dyn OffsetCommitCallback>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn commit_async_with_callback<'a>( &'a mut self, callback: Arc<dyn OffsetCommitCallback>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::commit_async_with_callback.
§Arguments
callback- asConsumer::commit_async_with_callback.
§Errors
Sourcefn commit_async_with_offsets_callback<'a>(
&'a mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
callback: Arc<dyn OffsetCommitCallback>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn commit_async_with_offsets_callback<'a>( &'a mut self, offsets: HashMap<TopicPartition, OffsetAndMetadata>, callback: Arc<dyn OffsetCommitCallback>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::commit_async_with_offsets_callback.
§Arguments
offsets- asConsumer::commit_async_with_offsets_callback.callback- asConsumer::commit_async_with_offsets_callback.
§Errors
Sourcefn seek_with_offset<'a>(
&'a mut self,
partition: TopicPartition,
offset: i64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn seek_with_offset<'a>( &'a mut self, partition: TopicPartition, offset: i64, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::seek_with_offset.
§Arguments
partition- asConsumer::seek_with_offset.offset- asConsumer::seek_with_offset.
§Errors
Sourcefn seek_with_offset_and_metadata<'a>(
&'a mut self,
partition: TopicPartition,
offset_and_metadata: OffsetAndMetadata,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn seek_with_offset_and_metadata<'a>( &'a mut self, partition: TopicPartition, offset_and_metadata: OffsetAndMetadata, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::seek_with_offset_and_metadata.
§Arguments
partition- asConsumer::seek_with_offset_and_metadata.offset_and_metadata- asConsumer::seek_with_offset_and_metadata.
§Errors
Sourcefn seek_to_beginning<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn seek_to_beginning<'a>( &'a mut self, partitions: &'a [TopicPartition], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn seek_to_end<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn seek_to_end<'a>( &'a mut self, partitions: &'a [TopicPartition], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn position<'a>(
&'a mut self,
partition: &'a TopicPartition,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'a>>
fn position<'a>( &'a mut self, partition: &'a TopicPartition, ) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'a>>
Sourcefn position_with_timeout<'a>(
&'a mut self,
partition: &'a TopicPartition,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'a>>
fn position_with_timeout<'a>( &'a mut self, partition: &'a TopicPartition, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'a>>
See Consumer::position_with_timeout.
§Arguments
partition- asConsumer::position_with_timeout.timeout- asConsumer::position_with_timeout.
§Returns
As Consumer::position_with_timeout.
§Errors
Sourcefn committed<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>> + Send + 'a>>
fn committed<'a>( &'a mut self, partitions: &'a [TopicPartition], ) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>> + Send + 'a>>
Sourcefn committed_with_timeout<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>> + Send + 'a>>
fn committed_with_timeout<'a>( &'a mut self, partitions: &'a [TopicPartition], timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>> + Send + 'a>>
See Consumer::committed_with_timeout.
§Arguments
partitions- asConsumer::committed_with_timeout.timeout- asConsumer::committed_with_timeout.
§Returns
As Consumer::committed_with_timeout.
§Errors
Sourcefn partitions_for<'a>(
&'a mut self,
topic: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<PartitionInfo>, Error>> + Send + 'a>>
fn partitions_for<'a>( &'a mut self, topic: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<PartitionInfo>, Error>> + Send + 'a>>
Sourcefn partitions_for_with_timeout<'a>(
&'a mut self,
topic: &'a str,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<PartitionInfo>, Error>> + Send + 'a>>
fn partitions_for_with_timeout<'a>( &'a mut self, topic: &'a str, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<Vec<PartitionInfo>, Error>> + Send + 'a>>
See Consumer::partitions_for_with_timeout.
§Arguments
topic- asConsumer::partitions_for_with_timeout.timeout- asConsumer::partitions_for_with_timeout.
§Returns
As Consumer::partitions_for_with_timeout.
§Errors
Sourcefn list_topics<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send + 'a>>
fn list_topics<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send + 'a>>
Sourcefn list_topics_with_timeout<'a>(
&'a mut self,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send + 'a>>
fn list_topics_with_timeout<'a>( &'a mut self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send + 'a>>
See Consumer::list_topics_with_timeout.
§Arguments
timeout- asConsumer::list_topics_with_timeout.
§Returns
As Consumer::list_topics_with_timeout.
§Errors
Sourcefn offsets_for_times<'a>(
&'a mut self,
timestamps_to_search: HashMap<TopicPartition, i64>,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send + 'a>>
fn offsets_for_times<'a>( &'a mut self, timestamps_to_search: HashMap<TopicPartition, i64>, ) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send + 'a>>
See Consumer::offsets_for_times.
§Arguments
timestamps_to_search- asConsumer::offsets_for_times.
§Returns
As Consumer::offsets_for_times.
§Errors
Sourcefn offsets_for_times_with_timeout<'a>(
&'a mut self,
timestamps_to_search: HashMap<TopicPartition, i64>,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send + 'a>>
fn offsets_for_times_with_timeout<'a>( &'a mut self, timestamps_to_search: HashMap<TopicPartition, i64>, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send + 'a>>
See Consumer::offsets_for_times_with_timeout.
§Arguments
timestamps_to_search- asConsumer::offsets_for_times_with_timeout.timeout- asConsumer::offsets_for_times_with_timeout.
§Returns
As Consumer::offsets_for_times_with_timeout.
§Errors
Sourcefn beginning_offsets<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>
fn beginning_offsets<'a>( &'a mut self, partitions: &'a [TopicPartition], ) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>
See Consumer::beginning_offsets.
§Arguments
partitions- asConsumer::beginning_offsets.
§Returns
As Consumer::beginning_offsets.
§Errors
Sourcefn beginning_offsets_with_timeout<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>
fn beginning_offsets_with_timeout<'a>( &'a mut self, partitions: &'a [TopicPartition], timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>
See Consumer::beginning_offsets_with_timeout.
§Arguments
partitions- asConsumer::beginning_offsets_with_timeout.timeout- asConsumer::beginning_offsets_with_timeout.
§Returns
As Consumer::beginning_offsets_with_timeout.
§Errors
Sourcefn end_offsets<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>
fn end_offsets<'a>( &'a mut self, partitions: &'a [TopicPartition], ) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>
Sourcefn end_offsets_with_timeout<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>
fn end_offsets_with_timeout<'a>( &'a mut self, partitions: &'a [TopicPartition], timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<HashMap<TopicPartition, i64>, Error>> + Send + 'a>>
See Consumer::end_offsets_with_timeout.
§Arguments
partitions- asConsumer::end_offsets_with_timeout.timeout- asConsumer::end_offsets_with_timeout.
§Returns
As Consumer::end_offsets_with_timeout.
§Errors
Sourcefn pause<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn pause<'a>( &'a mut self, partitions: &'a [TopicPartition], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn resume<'a>(
&'a mut self,
partitions: &'a [TopicPartition],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn resume<'a>( &'a mut self, partitions: &'a [TopicPartition], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn enforce_rebalance<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn enforce_rebalance<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn enforce_rebalance_with_reason<'a>(
&'a mut self,
reason: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn enforce_rebalance_with_reason<'a>( &'a mut self, reason: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
See Consumer::enforce_rebalance_with_reason.
§Arguments
reason- asConsumer::enforce_rebalance_with_reason.
§Errors
Sourcefn close_with_options<'a>(
&'a mut self,
options: CloseOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn close_with_options<'a>( &'a mut self, options: CloseOptions, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Sourcefn wakeup(&self)
fn wakeup(&self)
See Consumer::wakeup.
Sourcefn handle(&self) -> ConsumerHandle
fn handle(&self) -> ConsumerHandle
Trait Implementations§
Source§impl<K, V> Consumer<K, V> for dyn DynConsumer<K, V>
impl<K, V> Consumer<K, V> for dyn DynConsumer<K, V>
Source§fn assignment(&mut self) -> HashSet<TopicPartition>
fn assignment(&mut self) -> HashSet<TopicPartition>
Self::assign then this will simply return the same partitions that
were assigned. If topic subscription was used, then this will give the
set of topic partitions currently assigned to the consumer (which may
be none if the assignment hasn’t happened yet, or the partitions are in
the process of getting reassigned). Read moreSource§fn subscription(&mut self) -> HashSet<String>
fn subscription(&mut self) -> HashSet<String>
Self::subscribe_with_topics or
Self::subscribe_with_topics_listener, or an empty set if no such
call has been made. Read moreSource§fn paused(&mut self) -> HashSet<TopicPartition>
fn paused(&mut self) -> HashSet<TopicPartition>
Self::pause. Read moreSource§fn group_metadata(&mut self) -> Arc<dyn ConsumerGroupMetadata>
fn group_metadata(&mut self) -> Arc<dyn ConsumerGroupMetadata>
Source§async fn current_lag(
&mut self,
topic_partition: &TopicPartition,
) -> Result<Option<i64>, Error>
async fn current_lag( &mut self, topic_partition: &TopicPartition, ) -> Result<Option<i64>, Error>
None if the
lag is not known, for example if there is no position yet, or if the
end offset is not known yet. Read moreSource§fn metrics(&self) -> MetricsView
fn metrics(&self) -> MetricsView
Source§fn subscribe_with_topics(
&mut self,
topics: Vec<String>,
) -> impl Future<Output = Result<(), Error>> + Send
fn subscribe_with_topics( &mut self, topics: Vec<String>, ) -> impl Future<Output = Result<(), Error>> + Send
Self::assign. If the given list of topics is
empty, it is treated the same as Self::unsubscribe. Read moreSource§fn subscribe_with_topics_listener(
&mut self,
topics: Vec<String>,
listener: Arc<dyn ConsumerRebalanceListener>,
) -> impl Future<Output = Result<(), Error>> + Send
fn subscribe_with_topics_listener( &mut self, topics: Vec<String>, listener: Arc<dyn ConsumerRebalanceListener>, ) -> impl Future<Output = Result<(), Error>> + Send
Self::assign. If the given list of
topics is empty, it is treated the same as Self::unsubscribe. Read moreSource§fn subscribe_with_pattern(
&mut self,
pattern: SubscriptionPattern,
) -> impl Future<Output = Result<(), Error>> + Send
fn subscribe_with_pattern( &mut self, pattern: SubscriptionPattern, ) -> impl Future<Output = Result<(), Error>> + Send
ConsumerConfig::GROUP_PROTOCOL_CONFIG) Read moreSource§fn subscribe_with_pattern_listener(
&mut self,
pattern: SubscriptionPattern,
listener: Arc<dyn ConsumerRebalanceListener>,
) -> impl Future<Output = Result<(), Error>> + Send
fn subscribe_with_pattern_listener( &mut self, pattern: SubscriptionPattern, listener: Arc<dyn ConsumerRebalanceListener>, ) -> impl Future<Output = Result<(), Error>> + Send
ConsumerConfig::GROUP_PROTOCOL_CONFIG). Read moreSource§fn assign(
&mut self,
partitions: Vec<TopicPartition>,
) -> impl Future<Output = Result<(), Error>> + Send
fn assign( &mut self, partitions: Vec<TopicPartition>, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn unsubscribe(&mut self) -> impl Future<Output = Result<(), Error>> + Send
fn unsubscribe(&mut self) -> impl Future<Output = Result<(), Error>> + Send
Self::subscribe_with_topics or Self::subscribe_with_pattern.
This also clears any partitions directly assigned through
Self::assign. Read moreSource§fn poll(
&mut self,
timeout: Duration,
) -> impl Future<Output = Result<ConsumerRecords<K, V>, Error>> + Send
fn poll( &mut self, timeout: Duration, ) -> impl Future<Output = Result<ConsumerRecords<K, V>, Error>> + Send
Source§fn commit_sync(&mut self) -> impl Future<Output = Result<(), Error>> + Send
fn commit_sync(&mut self) -> impl Future<Output = Result<(), Error>> + Send
Source§fn commit_sync_with_timeout(
&mut self,
timeout: Duration,
) -> impl Future<Output = Result<(), Error>> + Send
fn commit_sync_with_timeout( &mut self, timeout: Duration, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn commit_sync_with_offsets(
&mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
) -> impl Future<Output = Result<(), Error>> + Send
fn commit_sync_with_offsets( &mut self, offsets: HashMap<TopicPartition, OffsetAndMetadata>, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn commit_sync_with_offsets_timeout(
&mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
timeout: Duration,
) -> impl Future<Output = Result<(), Error>> + Send
fn commit_sync_with_offsets_timeout( &mut self, offsets: HashMap<TopicPartition, OffsetAndMetadata>, timeout: Duration, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn commit_async(&mut self) -> impl Future<Output = Result<(), Error>> + Send
fn commit_async(&mut self) -> impl Future<Output = Result<(), Error>> + Send
Self::poll for all the subscribed list of topics
and partition. Same as commitAsync(None) Read moreSource§fn commit_async_with_callback(
&mut self,
callback: Arc<dyn OffsetCommitCallback>,
) -> impl Future<Output = Result<(), Error>> + Send
fn commit_async_with_callback( &mut self, callback: Arc<dyn OffsetCommitCallback>, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn commit_async_with_offsets_callback(
&mut self,
offsets: HashMap<TopicPartition, OffsetAndMetadata>,
callback: Arc<dyn OffsetCommitCallback>,
) -> impl Future<Output = Result<(), Error>> + Send
fn commit_async_with_offsets_callback( &mut self, offsets: HashMap<TopicPartition, OffsetAndMetadata>, callback: Arc<dyn OffsetCommitCallback>, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn seek_with_offset(
&mut self,
partition: TopicPartition,
offset: i64,
) -> impl Future<Output = Result<(), Error>> + Send
fn seek_with_offset( &mut self, partition: TopicPartition, offset: i64, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn seek_with_offset_and_metadata(
&mut self,
partition: TopicPartition,
offset_and_metadata: OffsetAndMetadata,
) -> impl Future<Output = Result<(), Error>> + Send
fn seek_with_offset_and_metadata( &mut self, partition: TopicPartition, offset_and_metadata: OffsetAndMetadata, ) -> impl Future<Output = Result<(), Error>> + Send
poll(timeout). If this API is invoked for the same partition more than
once, the latest offset will be used on the next poll(). Note that you
may lose data if this API is arbitrarily used in the middle of
consumption, to reset the fetch offsets. This method allows for setting
the leaderEpoch along with the desired offset. Read moreSource§async fn seek_to_beginning(
&mut self,
partitions: &[TopicPartition],
) -> Result<(), Error>
async fn seek_to_beginning( &mut self, partitions: &[TopicPartition], ) -> Result<(), Error>
Self::poll or Self::position are called. If no partitions are
provided, seek to the first offset for all of the currently assigned
partitions. Read moreSource§async fn seek_to_end(
&mut self,
partitions: &[TopicPartition],
) -> Result<(), Error>
async fn seek_to_end( &mut self, partitions: &[TopicPartition], ) -> Result<(), Error>
Self::poll or Self::position are called. If no partitions are
provided, seek to the final offset for all of the currently assigned
partitions. Read moreSource§async fn position(&mut self, partition: &TopicPartition) -> Result<i64, Error>
async fn position(&mut self, partition: &TopicPartition) -> Result<i64, Error>
Source§async fn position_with_timeout(
&mut self,
partition: &TopicPartition,
timeout: Duration,
) -> Result<i64, Error>
async fn position_with_timeout( &mut self, partition: &TopicPartition, timeout: Duration, ) -> Result<i64, Error>
Source§async fn committed(
&mut self,
partitions: &[TopicPartition],
) -> Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>
async fn committed( &mut self, partitions: &[TopicPartition], ) -> Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>
Source§async fn committed_with_timeout(
&mut self,
partitions: &[TopicPartition],
timeout: Duration,
) -> Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>
async fn committed_with_timeout( &mut self, partitions: &[TopicPartition], timeout: Duration, ) -> Result<HashMap<TopicPartition, Option<OffsetAndMetadata>>, Error>
Source§async fn partitions_for(
&mut self,
topic: &str,
) -> Result<Vec<PartitionInfo>, Error>
async fn partitions_for( &mut self, topic: &str, ) -> Result<Vec<PartitionInfo>, Error>
Source§async fn partitions_for_with_timeout(
&mut self,
topic: &str,
timeout: Duration,
) -> Result<Vec<PartitionInfo>, Error>
async fn partitions_for_with_timeout( &mut self, topic: &str, timeout: Duration, ) -> Result<Vec<PartitionInfo>, Error>
Source§fn list_topics(
&mut self,
) -> impl Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send
fn list_topics( &mut self, ) -> impl Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send
Source§fn list_topics_with_timeout(
&mut self,
timeout: Duration,
) -> impl Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send
fn list_topics_with_timeout( &mut self, timeout: Duration, ) -> impl Future<Output = Result<HashMap<String, Vec<PartitionInfo>>, Error>> + Send
Source§fn offsets_for_times(
&mut self,
timestamps_to_search: HashMap<TopicPartition, i64>,
) -> impl Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send
fn offsets_for_times( &mut self, timestamps_to_search: HashMap<TopicPartition, i64>, ) -> impl Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send
None will be returned for
that partition. Read moreSource§fn offsets_for_times_with_timeout(
&mut self,
timestamps_to_search: HashMap<TopicPartition, i64>,
timeout: Duration,
) -> impl Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send
fn offsets_for_times_with_timeout( &mut self, timestamps_to_search: HashMap<TopicPartition, i64>, timeout: Duration, ) -> impl Future<Output = Result<HashMap<TopicPartition, Option<OffsetAndTimestamp>>, Error>> + Send
None will be returned for
that partition. Read moreSource§async fn beginning_offsets(
&mut self,
partitions: &[TopicPartition],
) -> Result<HashMap<TopicPartition, i64>, Error>
async fn beginning_offsets( &mut self, partitions: &[TopicPartition], ) -> Result<HashMap<TopicPartition, i64>, Error>
Source§async fn beginning_offsets_with_timeout(
&mut self,
partitions: &[TopicPartition],
timeout: Duration,
) -> Result<HashMap<TopicPartition, i64>, Error>
async fn beginning_offsets_with_timeout( &mut self, partitions: &[TopicPartition], timeout: Duration, ) -> Result<HashMap<TopicPartition, i64>, Error>
Source§async fn end_offsets(
&mut self,
partitions: &[TopicPartition],
) -> Result<HashMap<TopicPartition, i64>, Error>
async fn end_offsets( &mut self, partitions: &[TopicPartition], ) -> Result<HashMap<TopicPartition, i64>, Error>
read_uncommitted
isolation level, the end offset is the high watermark (that is, the offset of the last
successfully replicated message plus one). For read_committed consumers, the end
offset is the last stable offset (LSO), which is the minimum of the high watermark and
the smallest offset of any open transaction. Finally, if the partition has never been
written to, the end offset is 0. Read moreSource§async fn end_offsets_with_timeout(
&mut self,
partitions: &[TopicPartition],
timeout: Duration,
) -> Result<HashMap<TopicPartition, i64>, Error>
async fn end_offsets_with_timeout( &mut self, partitions: &[TopicPartition], timeout: Duration, ) -> Result<HashMap<TopicPartition, i64>, Error>
read_uncommitted
isolation level, the end offset is the high watermark (that is, the offset of the last
successfully replicated message plus one). For read_committed consumers, the end
offset is the last stable offset (LSO), which is the minimum of the high watermark and
the smallest offset of any open transaction. Finally, if the partition has never been
written to, the end offset is 0. Read moreSource§async fn pause(&mut self, partitions: &[TopicPartition]) -> Result<(), Error>
async fn pause(&mut self, partitions: &[TopicPartition]) -> Result<(), Error>
Self::poll will not return any records from these partitions until
they have been resumed using Self::resume. Note that this method
does not affect partition subscription. In particular, it does not cause
a group rebalance when automatic assignment is used. Read moreSource§async fn resume(&mut self, partitions: &[TopicPartition]) -> Result<(), Error>
async fn resume(&mut self, partitions: &[TopicPartition]) -> Result<(), Error>
Self::pause. New calls to
Self::poll will return records from these partitions if there are any to be fetched.
If the partitions were not previously paused, this method is a no-op. Read moreSource§fn enforce_rebalance(
&mut self,
) -> impl Future<Output = Result<(), Error>> + Send
fn enforce_rebalance( &mut self, ) -> impl Future<Output = Result<(), Error>> + Send
Self::poll call. Note that this API does not
itself initiate the rebalance, so you must still call Self::poll. If
a rebalance is already in progress this call will be a no-op. If you wish
to force an additional rebalance you must complete the current one by
calling poll before retrying this API. Read moreSource§async fn enforce_rebalance_with_reason(
&mut self,
reason: &str,
) -> Result<(), Error>
async fn enforce_rebalance_with_reason( &mut self, reason: &str, ) -> Result<(), Error>
Self::poll call. Note that this API does not
itself initiate the rebalance, so you must still call Self::poll. If
a rebalance is already in progress this call will be a no-op. If you wish
to force an additional rebalance you must complete the current one by
calling poll before retrying this API. Read moreSource§fn close(&mut self) -> impl Future<Output = Result<(), Error>> + Send
fn close(&mut self) -> impl Future<Output = Result<(), Error>> + Send
Self::close for
details. Note that Self::wakeup cannot be used to interrupt close. Read moreSource§fn close_with_options(
&mut self,
options: CloseOptions,
) -> impl Future<Output = Result<(), Error>> + Send
fn close_with_options( &mut self, options: CloseOptions, ) -> impl Future<Output = Result<(), Error>> + Send
CloseOptions allows to specify a timeout
and a leave group behavior. If no timeout is specified, the default
timeout of 30 seconds is used. If no leave group behavior is specified,
the default leave group behavior is used. Read moreSource§fn wakeup(&self)
fn wakeup(&self)
WakeupError. If no
thread is blocking in a method which can throw WakeupError, the next call to such a
method will raise it instead. Read moreSource§fn handle(&self) -> ConsumerHandle
fn handle(&self) -> ConsumerHandle
Clone + Send + Sync ConsumerHandle exposing
Consumer::wakeup and the reentrant-safe consumer operations,
callable from a task / thread other than the one that owns the
consumer. Read more