Skip to main content

OffsetStore

Trait OffsetStore 

Source
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§

Source

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

Source

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.

Source

fn delete(&self, topic_id: u32, consumer_id: u64) -> Result<(), ClientError>

Delete stored offset for a topic and consumer

Use when resetting consumer position or cleaning up.

Source

fn list_all(&self) -> Result<HashMap<(u32, u64), u64>, ClientError>

List all stored offsets

Returns a map of (topic_id, consumer_id) -> offset

Implementors§