pub struct OffsetTracker { /* private fields */ }Expand description
Tracks processing offsets with configurable commit strategies.
The OffsetTracker wraps an OffsetStore and provides convenient
methods for tracking and committing offsets based on the configured
strategy.
Implementations§
Source§impl OffsetTracker
impl OffsetTracker
Sourcepub fn new(store: Box<dyn OffsetStore>) -> Self
pub fn new(store: Box<dyn OffsetStore>) -> Self
Creates a new offset tracker with the given store and default settings.
Sourcepub fn with_strategy(
store: Box<dyn OffsetStore>,
strategy: CommitStrategy,
) -> Self
pub fn with_strategy( store: Box<dyn OffsetStore>, strategy: CommitStrategy, ) -> Self
Creates a new offset tracker with the specified commit strategy.
Sourcepub fn with_reset_policy(self, policy: OffsetResetPolicy) -> Self
pub fn with_reset_policy(self, policy: OffsetResetPolicy) -> Self
Sets the offset reset policy.
Sourcepub fn get_offset(&self, source: &str) -> OffsetResult<Offset>
pub fn get_offset(&self, source: &str) -> OffsetResult<Offset>
Gets the current committed offset for a source, applying the reset policy if no offset is found.
Sourcepub fn record(&self, source: &str, offset: Offset) -> OffsetResult<()>
pub fn record(&self, source: &str, offset: Offset) -> OffsetResult<()>
Records that an offset has been processed.
Based on the commit strategy, this may immediately commit the offset or hold it for later batch commit.
Sourcepub fn commit(&self, source: &str) -> OffsetResult<()>
pub fn commit(&self, source: &str) -> OffsetResult<()>
Commits the pending offset for a specific source.
This is useful for manual commit strategy or when forcing a commit.
Sourcepub fn commit_all(&self) -> OffsetResult<()>
pub fn commit_all(&self) -> OffsetResult<()>
Commits all pending offsets.
Sourcepub fn reset(&self, source: &str, offset: Offset) -> OffsetResult<()>
pub fn reset(&self, source: &str, offset: Offset) -> OffsetResult<()>
Resets the offset for a source to the specified value.
Sourcepub fn clear(&self, source: &str) -> OffsetResult<()>
pub fn clear(&self, source: &str) -> OffsetResult<()>
Clears the offset for a source.
Sourcepub fn strategy(&self) -> CommitStrategy
pub fn strategy(&self) -> CommitStrategy
Returns the current commit strategy.
Sourcepub fn reset_policy(&self) -> OffsetResetPolicy
pub fn reset_policy(&self) -> OffsetResetPolicy
Returns the current reset policy.
Sourcepub fn get_all_committed(&self) -> OffsetResult<HashMap<String, Offset>>
pub fn get_all_committed(&self) -> OffsetResult<HashMap<String, Offset>>
Gets all committed offsets.
Sourcepub fn get_all_pending(&self) -> OffsetResult<HashMap<String, Offset>>
pub fn get_all_pending(&self) -> OffsetResult<HashMap<String, Offset>>
Gets all pending offsets (not yet committed).