pub struct CheckpointStore { /* private fields */ }Expand description
Persistent checkpoint store with bounded history per (stream, partition) key.
The store always keeps the latest checkpoint as the authoritative offset
and additionally retains up to max_history older entries for auditing or
replay purposes.
Implementations§
Source§impl CheckpointStore
impl CheckpointStore
Sourcepub fn commit(&mut self, checkpoint: Checkpoint)
pub fn commit(&mut self, checkpoint: Checkpoint)
Commit a checkpoint.
Updates the latest offset for the (stream, partition) key and appends the entry to the rolling history buffer.
Sourcepub fn get(&self, stream_id: &str, partition: u32) -> Option<&Checkpoint>
pub fn get(&self, stream_id: &str, partition: u32) -> Option<&Checkpoint>
Return a reference to the latest checkpoint for a (stream, partition) pair.
Sourcepub fn latest_offset(&self, stream_id: &str, partition: u32) -> Option<i64>
pub fn latest_offset(&self, stream_id: &str, partition: u32) -> Option<i64>
Return the latest committed offset, if any.
Sourcepub fn reset(&mut self, stream_id: &str, partition: u32)
pub fn reset(&mut self, stream_id: &str, partition: u32)
Remove the checkpoint for the given (stream, partition) key.
Historical entries for this key are not removed so that auditing still works.
Sourcepub fn reset_to(&mut self, stream_id: &str, partition: u32, offset: i64) -> bool
pub fn reset_to(&mut self, stream_id: &str, partition: u32, offset: i64) -> bool
Roll back the checkpoint to a specific offset.
Returns true if a checkpoint existed and was updated, false otherwise.
Historical entries are preserved unchanged.
Sourcepub fn all_streams(&self) -> Vec<&str>
pub fn all_streams(&self) -> Vec<&str>
Return all stream IDs that have at least one active checkpoint.
Sourcepub fn partitions(&self, stream_id: &str) -> Vec<u32>
pub fn partitions(&self, stream_id: &str) -> Vec<u32>
Return all active partitions for a given stream.
Sourcepub fn history(&self, stream_id: &str, partition: u32) -> Vec<&Checkpoint>
pub fn history(&self, stream_id: &str, partition: u32) -> Vec<&Checkpoint>
Return historical checkpoints for a (stream, partition) pair, oldest first.
Sourcepub fn total_committed(&self) -> usize
pub fn total_committed(&self) -> usize
Return the total number of commits across all partitions and streams.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CheckpointStore
impl RefUnwindSafe for CheckpointStore
impl Send for CheckpointStore
impl Sync for CheckpointStore
impl Unpin for CheckpointStore
impl UnsafeUnpin for CheckpointStore
impl UnwindSafe for CheckpointStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.