Consumer

Struct Consumer 

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

A consumer that reads from specific partitions of a topic.

Implementations§

Source§

impl Consumer

Source

pub fn new(topic_name: &str, group: &str) -> Self

Create a new consumer for the named topic and consumer group.

Source

pub fn assign(&mut self, partitions: &[u32])

Assign specific partitions to this consumer.

Source

pub fn seek( &mut self, mgr: &TopicManager, offset_store: &dyn OffsetStore, policy: SeekPolicy, ) -> Result<()>

Initialize read offsets according to the seek policy.

Source

pub fn poll( &mut self, mgr: &TopicManager, max_messages: usize, ) -> Result<Vec<(u32, Message)>>

Poll for the next batch of messages across all assigned partitions.

Returns up to max_messages messages. Messages are interleaved across partitions in round-robin order.

Source

pub fn commit(&self, offset_store: &mut dyn OffsetStore)

Commit the current read offsets to the offset store.

Source

pub fn assigned_partitions(&self) -> &[u32]

Returns the assigned partitions.

Source

pub fn group(&self) -> &str

Returns the consumer group name.

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, 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, 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.