pub struct ConsumerGroupManager { /* private fields */ }Expand description
Owns all consumer groups for a single CDC ring.
Provides the full group lifecycle: creation, per-consumer reads, acknowledgement, pending-entry inspection, ownership transfer (claim), and gap detection.
Implementations§
Source§impl ConsumerGroupManager
impl ConsumerGroupManager
Sourcepub fn new(default_idle_timeout: Duration) -> Self
pub fn new(default_idle_timeout: Duration) -> Self
Create a manager whose newly created groups use default_idle_timeout
for pending-entry redelivery.
Sourcepub fn create_group(
&mut self,
name: &str,
start_seq: u64,
) -> Result<(), ConsumerGroupError>
pub fn create_group( &mut self, name: &str, start_seq: u64, ) -> Result<(), ConsumerGroupError>
Create a consumer group that begins delivering events at start_seq.
Returns ConsumerGroupError::GroupExists if name is already taken.
Sourcepub fn read_group(
&mut self,
ring: &CdcRing,
group_name: &str,
consumer_name: &str,
count: usize,
) -> Result<GroupReadResult, ConsumerGroupError>
pub fn read_group( &mut self, ring: &CdcRing, group_name: &str, consumer_name: &str, count: usize, ) -> Result<GroupReadResult, ConsumerGroupError>
Deliver up to count events to consumer_name within group_name.
Before reading fresh events from the ring, timed-out pending entries owned by other consumers are reclaimed and delivered first. The consumer is auto-created if it does not already exist.
Sourcepub fn ack(
&mut self,
group_name: &str,
seqs: &[u64],
) -> Result<usize, ConsumerGroupError>
pub fn ack( &mut self, group_name: &str, seqs: &[u64], ) -> Result<usize, ConsumerGroupError>
Acknowledge one or more events by sequence number.
Acknowledged entries are removed from every consumer’s pending list within the group. Returns the total number of entries removed.
Sourcepub fn pending(
&self,
group_name: &str,
) -> Result<Vec<PendingSummary>, ConsumerGroupError>
pub fn pending( &self, group_name: &str, ) -> Result<Vec<PendingSummary>, ConsumerGroupError>
Return a snapshot of every pending entry across all consumers in the group, sorted by sequence number.
Sourcepub fn claim(
&mut self,
group_name: &str,
target_consumer: &str,
min_idle: Duration,
seqs: &[u64],
) -> Result<Vec<u64>, ConsumerGroupError>
pub fn claim( &mut self, group_name: &str, target_consumer: &str, min_idle: Duration, seqs: &[u64], ) -> Result<Vec<u64>, ConsumerGroupError>
Transfer ownership of pending entries to target_consumer.
Only entries whose idle time meets or exceeds min_idle are
transferred. Returns the sequence numbers that were claimed.
Sourcepub fn group_count(&self) -> usize
pub fn group_count(&self) -> usize
Return the number of registered groups.
Sourcepub fn check_gap(
&mut self,
ring: &CdcRing,
group_name: &str,
consumer_name: &str,
) -> Result<bool, ConsumerGroupError>
pub fn check_gap( &mut self, ring: &CdcRing, group_name: &str, consumer_name: &str, ) -> Result<bool, ConsumerGroupError>
Check whether consumer_name in group_name has fallen behind the ring.
Returns true if the consumer’s last acknowledged sequence has been
evicted from the ring, or if the consumer was already marked for resync.