pub struct Consumer { /* private fields */ }Expand description
A consumer that reads from specific partitions of a topic.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn new(topic_name: &str, group: &str) -> Self
pub fn new(topic_name: &str, group: &str) -> Self
Create a new consumer for the named topic and consumer group.
Sourcepub fn seek(
&mut self,
mgr: &TopicManager,
offset_store: &dyn OffsetStore,
policy: SeekPolicy,
) -> Result<()>
pub fn seek( &mut self, mgr: &TopicManager, offset_store: &dyn OffsetStore, policy: SeekPolicy, ) -> Result<()>
Initialize read offsets according to the seek policy.
Sourcepub fn poll(
&mut self,
mgr: &TopicManager,
max_messages: usize,
) -> Result<Vec<(u32, Message)>>
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.
Sourcepub fn commit(&self, offset_store: &mut dyn OffsetStore)
pub fn commit(&self, offset_store: &mut dyn OffsetStore)
Commit the current read offsets to the offset store.
Sourcepub fn assigned_partitions(&self) -> &[u32]
pub fn assigned_partitions(&self) -> &[u32]
Returns the assigned partitions.
Auto Trait Implementations§
impl Freeze for Consumer
impl RefUnwindSafe for Consumer
impl Send for Consumer
impl Sync for Consumer
impl Unpin for Consumer
impl UnwindSafe for Consumer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more