pub trait OffsetStore: Send + Sync {
// Required methods
fn load(
&self,
topic_id: u32,
consumer_id: u64,
) -> Result<Option<u64>, ClientError>;
fn save(
&self,
topic_id: u32,
consumer_id: u64,
offset: u64,
) -> Result<(), ClientError>;
fn delete(&self, topic_id: u32, consumer_id: u64) -> Result<(), ClientError>;
fn list_all(&self) -> Result<HashMap<(u32, u64), u64>, ClientError>;
}Expand description
Trait for client-side offset persistence
Implementations store consumer offsets locally, allowing consumers to resume from their last position after restarts without server-side state.
Required Methods§
Sourcefn load(
&self,
topic_id: u32,
consumer_id: u64,
) -> Result<Option<u64>, ClientError>
fn load( &self, topic_id: u32, consumer_id: u64, ) -> Result<Option<u64>, ClientError>
Load the stored offset for a topic and consumer
Returns None if no offset has been stored (first run).
Sourcefn save(
&self,
topic_id: u32,
consumer_id: u64,
offset: u64,
) -> Result<(), ClientError>
fn save( &self, topic_id: u32, consumer_id: u64, offset: u64, ) -> Result<(), ClientError>
Save the current offset for a topic and consumer
This should be called after successfully processing records.