Skip to main content

OffsetStore

Trait OffsetStore 

Source
pub trait OffsetStore: Send + Sync {
    // Required methods
    fn store_offset<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        consumer_group: &'life1 str,
        topic_partition: &'life2 TopicPartition,
        offset_info: &'life3 OffsetInfo,
    ) -> Pin<Box<dyn Future<Output = StateResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn get_offset<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        consumer_group: &'life1 str,
        topic_partition: &'life2 TopicPartition,
    ) -> Pin<Box<dyn Future<Output = StateResult<Option<OffsetInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_all_offsets<'life0, 'life1, 'async_trait>(
        &'life0 self,
        consumer_group: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StateResult<HashMap<TopicPartition, OffsetInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_offset<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        consumer_group: &'life1 str,
        topic_partition: &'life2 TopicPartition,
    ) -> Pin<Box<dyn Future<Output = StateResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn clear_offsets<'life0, 'life1, 'async_trait>(
        &'life0 self,
        consumer_group: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StateResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for offset storage backends

Implementations can store offsets in memory, state backends, external systems, or Kafka itself.

Required Methods§

Source

fn store_offset<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, consumer_group: &'life1 str, topic_partition: &'life2 TopicPartition, offset_info: &'life3 OffsetInfo, ) -> Pin<Box<dyn Future<Output = StateResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Store offset for a topic-partition

§Arguments
  • consumer_group - Consumer group ID
  • topic_partition - Topic and partition
  • offset_info - Offset information to store
§Returns
  • Ok(()) - Offset stored successfully
  • Err(StateError) - Storage failed
Source

fn get_offset<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, consumer_group: &'life1 str, topic_partition: &'life2 TopicPartition, ) -> Pin<Box<dyn Future<Output = StateResult<Option<OffsetInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieve offset for a topic-partition

§Arguments
  • consumer_group - Consumer group ID
  • topic_partition - Topic and partition
§Returns
  • Ok(Some(OffsetInfo)) - Offset found
  • Ok(None) - No offset stored
  • Err(StateError) - Retrieval failed
Source

fn get_all_offsets<'life0, 'life1, 'async_trait>( &'life0 self, consumer_group: &'life1 str, ) -> Pin<Box<dyn Future<Output = StateResult<HashMap<TopicPartition, OffsetInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all offsets for a consumer group

§Arguments
  • consumer_group - Consumer group ID
§Returns
  • Ok(HashMap) - Map of topic-partitions to offset info
  • Err(StateError) - Retrieval failed
Source

fn delete_offset<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, consumer_group: &'life1 str, topic_partition: &'life2 TopicPartition, ) -> Pin<Box<dyn Future<Output = StateResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete offset for a topic-partition

§Arguments
  • consumer_group - Consumer group ID
  • topic_partition - Topic and partition
§Returns
  • Ok(()) - Offset deleted
  • Err(StateError) - Deletion failed
Source

fn clear_offsets<'life0, 'life1, 'async_trait>( &'life0 self, consumer_group: &'life1 str, ) -> Pin<Box<dyn Future<Output = StateResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Clear all offsets for a consumer group

§Arguments
  • consumer_group - Consumer group ID
§Returns
  • Ok(()) - All offsets cleared
  • Err(StateError) - Clear failed

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§