Skip to main content

KafkaConsumer

Struct KafkaConsumer 

Source
pub struct KafkaConsumer { /* private fields */ }
Expand description

A Kafka group consumer with explicit polling and commits.

Implementations§

Source§

impl KafkaConsumer

Source

pub async fn connect(config: ConsumerConfig) -> Result<Self>

Connects to Kafka and returns the client.

Source

pub fn with_default_poll_timeout(self, timeout: Duration) -> Self

Sets default poll timeout and returns the updated value.

Source

pub async fn subscribe(&self, topics: Vec<String>) -> Result<()>

Subscribe.

Source

pub async fn subscribe_pattern( &self, pattern: SubscriptionPattern, ) -> Result<()>

Subscribe Pattern.

Source

pub async fn subscribe_regex(&self, pattern: String) -> Result<()>

Subscribe Regex.

Source

pub async fn unsubscribe(&self) -> Result<()>

Unsubscribe.

Source

pub async fn poll(&self) -> Result<ConsumerRecords>

Polls Kafka for records.

Source

pub async fn poll_for(&self, timeout: Duration) -> Result<ConsumerRecords>

Poll For.

Source

pub async fn assign(&self, partitions: Vec<TopicPartition>) -> Result<()>

Assign.

Source

pub async fn seek(&self, partition: TopicPartition, offset: i64) -> Result<()>

Seek.

Source

pub async fn seek_to_beginning( &self, partitions: Vec<TopicPartition>, ) -> Result<()>

Seek To Beginning.

Source

pub async fn seek_to_end(&self, partitions: Vec<TopicPartition>) -> Result<()>

Seek To End.

Source

pub async fn seek_to_timestamp( &self, partitions: Vec<TopicPartitionTimestamp>, ) -> Result<()>

Seek To Timestamp.

Source

pub async fn position(&self, partition: TopicPartition) -> Result<i64>

Position.

Source

pub async fn pause(&self, partitions: Vec<TopicPartition>) -> Result<()>

Pause.

Source

pub async fn resume(&self, partitions: Vec<TopicPartition>) -> Result<()>

Resume.

Source

pub async fn group_metadata(&self) -> Result<ConsumerGroupMetadata>

Group Metadata.

Source

pub async fn assignment(&self) -> Result<BTreeSet<TopicPartition>>

Assignment.

Source

pub async fn committed( &self, partitions: Vec<TopicPartition>, ) -> Result<Vec<TopicPartitionOffset>>

Committed.

Source

pub async fn beginning_offsets( &self, partitions: Vec<TopicPartition>, ) -> Result<Vec<TopicPartitionOffset>>

Beginning Offsets.

Source

pub async fn end_offsets( &self, partitions: Vec<TopicPartition>, ) -> Result<Vec<TopicPartitionOffset>>

End Offsets.

Source

pub async fn offsets_for_times( &self, partitions: Vec<TopicPartitionTimestamp>, ) -> Result<Vec<TopicPartitionOffsetAndTimestamp>>

Offsets For Times.

Source

pub async fn partitions_for( &self, topic: String, ) -> Result<Vec<TopicPartitionInfo>>

Partitions For.

Source

pub async fn list_topics(&self) -> Result<Vec<String>>

List Topics.

Source

pub async fn commit(&self, records: &ConsumerRecords) -> Result<()>

Commit.

Source

pub async fn commit_offsets(&self, offsets: Vec<CommitOffset>) -> Result<()>

Commit Offsets.

Source

pub async fn wakeup(&self) -> Result<()>

Wakeup.

Source

pub async fn shutdown(self) -> Result<()>

Shuts the client down and waits for in-flight work to finish.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more