pub struct CheckpointManager { /* private fields */ }Expand description
Drives periodic checkpointing and provides recovery support.
Call Self::on_event after processing each event. When the cumulative sequence
number reaches the next scheduled checkpoint, a new CheckpointState is
automatically saved to the underlying store.
Implementations§
Source§impl CheckpointManager
impl CheckpointManager
Sourcepub fn new(store: InMemoryCheckpointStore, checkpoint_interval: u64) -> Self
pub fn new(store: InMemoryCheckpointStore, checkpoint_interval: u64) -> Self
Create a manager with the given store and interval.
Sourcepub fn on_event(
&mut self,
stream_id: &str,
sequence: u64,
watermark_ns: u64,
) -> Result<bool, StreamingError>
pub fn on_event( &mut self, stream_id: &str, sequence: u64, watermark_ns: u64, ) -> Result<bool, StreamingError>
Called after each processed event.
Returns Ok(true) if a checkpoint was taken, Ok(false) otherwise.
Sourcepub fn recover(&self, stream_id: &str) -> Option<u64>
pub fn recover(&self, stream_id: &str) -> Option<u64>
Return the sequence number from which to resume, or None if no
checkpoint exists for the stream.
Sourcepub fn total_checkpoints(&self) -> u64
pub fn total_checkpoints(&self) -> u64
Total checkpoints taken since this manager was created.
Sourcepub fn store(&self) -> &InMemoryCheckpointStore
pub fn store(&self) -> &InMemoryCheckpointStore
Read-only access to the underlying store (for inspection / testing).
Auto Trait Implementations§
impl Freeze for CheckpointManager
impl RefUnwindSafe for CheckpointManager
impl Send for CheckpointManager
impl Sync for CheckpointManager
impl Unpin for CheckpointManager
impl UnsafeUnpin for CheckpointManager
impl UnwindSafe for CheckpointManager
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
Mutably borrows from an owned value. Read more