OffsetTracker

Struct OffsetTracker 

Source
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

Source

pub fn new(store: Box<dyn OffsetStore>) -> Self

Creates a new offset tracker with the given store and default settings.

Source

pub fn with_strategy( store: Box<dyn OffsetStore>, strategy: CommitStrategy, ) -> Self

Creates a new offset tracker with the specified commit strategy.

Source

pub fn with_reset_policy(self, policy: OffsetResetPolicy) -> Self

Sets the offset reset policy.

Source

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.

Source

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.

Source

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.

Source

pub fn commit_all(&self) -> OffsetResult<()>

Commits all pending offsets.

Source

pub fn reset(&self, source: &str, offset: Offset) -> OffsetResult<()>

Resets the offset for a source to the specified value.

Source

pub fn clear(&self, source: &str) -> OffsetResult<()>

Clears the offset for a source.

Source

pub fn strategy(&self) -> CommitStrategy

Returns the current commit strategy.

Source

pub fn reset_policy(&self) -> OffsetResetPolicy

Returns the current reset policy.

Source

pub fn get_all_committed(&self) -> OffsetResult<HashMap<String, Offset>>

Gets all committed offsets.

Source

pub fn get_all_pending(&self) -> OffsetResult<HashMap<String, Offset>>

Gets all pending offsets (not yet committed).

Trait Implementations§

Source§

impl Debug for OffsetTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.