pub struct ConsumerGroup {
pub group_id: String,
pub members: HashMap<SubscriberId, HashSet<String>>,
pub committed_offsets: HashMap<String, u64>,
pub created_at: u64,
}Expand description
A consumer group that coordinates message consumption across multiple subscribers.
Each member is assigned a set of channels, and the group tracks committed offsets per channel so that consumers can resume from where they left off.
Fields§
§group_id: StringUnique identifier for this consumer group.
members: HashMap<SubscriberId, HashSet<String>>Map of subscriber_id -> set of assigned channel names.
committed_offsets: HashMap<String, u64>Map of channel_name -> committed offset.
created_at: u64Timestamp when the group was created.
Implementations§
Source§impl ConsumerGroup
impl ConsumerGroup
Sourcepub fn add_member(
&mut self,
subscriber_id: SubscriberId,
channels: HashSet<String>,
)
pub fn add_member( &mut self, subscriber_id: SubscriberId, channels: HashSet<String>, )
Add a member to the consumer group with an initial set of assigned channels.
Sourcepub fn remove_member(
&mut self,
subscriber_id: &SubscriberId,
) -> Option<HashSet<String>>
pub fn remove_member( &mut self, subscriber_id: &SubscriberId, ) -> Option<HashSet<String>>
Remove a member from the consumer group. Returns the channels that were assigned to the removed member, or None if the member was not found.
Sourcepub fn commit_offset(&mut self, channel_name: impl Into<String>, offset: u64)
pub fn commit_offset(&mut self, channel_name: impl Into<String>, offset: u64)
Commit an offset for a channel. This records the position up to which messages have been successfully processed.
Sourcepub fn get_offset(&self, channel_name: &str) -> Option<u64>
pub fn get_offset(&self, channel_name: &str) -> Option<u64>
Get the committed offset for a channel. Returns None if no offset has been committed for that channel.
Sourcepub fn member_count(&self) -> usize
pub fn member_count(&self) -> usize
Get the number of members in the group.
Sourcepub fn is_member(&self, subscriber_id: &SubscriberId) -> bool
pub fn is_member(&self, subscriber_id: &SubscriberId) -> bool
Check if a subscriber is a member of this group.
Sourcepub fn get_member_channels(
&self,
subscriber_id: &SubscriberId,
) -> Option<&HashSet<String>>
pub fn get_member_channels( &self, subscriber_id: &SubscriberId, ) -> Option<&HashSet<String>>
Get the channels assigned to a specific member.
Trait Implementations§
Source§impl Clone for ConsumerGroup
impl Clone for ConsumerGroup
Source§fn clone(&self) -> ConsumerGroup
fn clone(&self) -> ConsumerGroup
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more