pub struct CheckpointStore { /* private fields */ }Expand description
File-backed store of paused workflow checkpoints, keyed by run_id.
Implementations§
Source§impl CheckpointStore
impl CheckpointStore
Sourcepub fn open(dir: impl AsRef<Path>) -> Result<Self>
pub fn open(dir: impl AsRef<Path>) -> Result<Self>
Open (creating if needed) a checkpoint store rooted at dir.
Sourcepub fn save(&self, paused: &PausedWorkflow) -> Result<()>
pub fn save(&self, paused: &PausedWorkflow) -> Result<()>
Persist a paused run. Write-to-temp + atomic rename so no half-written
checkpoint is ever visible. The temp name carries a fresh UUID so
concurrent writers for the same run_id never share a temp path.
Sourcepub fn load(&self, run_id: &str) -> Result<Option<PausedWorkflow>>
pub fn load(&self, run_id: &str) -> Result<Option<PausedWorkflow>>
Load a paused run by id without claiming it, or None if absent.
Read-only peek — does not protect against double-resume; use claim
for that.
Sourcepub fn claim(&self, run_id: &str) -> Result<Option<PausedWorkflow>>
pub fn claim(&self, run_id: &str) -> Result<Option<PausedWorkflow>>
Atomically take ownership of a paused run for resumption.
Renames <run_id>.json to <run_id>.inflight (atomic) and returns the
checkpoint. A second concurrent or duplicate claim finds no .json and
gets None — this is the exactly-once guard against double-resume.
After resuming, call save (if it paused again)
then complete.
Sourcepub fn recover_orphaned(&self) -> Result<usize>
pub fn recover_orphaned(&self) -> Result<usize>
Recover runs orphaned by a crash between claim
and complete. Call once at startup,
before any resume can be in flight — running it concurrently with a live
resume could re-arm a run another caller is mid-way through.
For each <run_id>.inflight: if a sibling <run_id>.json exists (a crash
after a re-pause save), the .json is authoritative and the stale marker
is removed; otherwise the marker is renamed back to <run_id>.json,
re-arming the run for a fresh claim. Returns the number re-armed.
Sourcepub fn complete(&self, run_id: &str) -> Result<()>
pub fn complete(&self, run_id: &str) -> Result<()>
Drop the in-flight marker after a claimed run finishes resuming.
Idempotent. Leaves any fresh <run_id>.json written by a re-pause.
Trait Implementations§
Source§impl Clone for CheckpointStore
impl Clone for CheckpointStore
Source§fn clone(&self) -> CheckpointStore
fn clone(&self) -> CheckpointStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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 more