pub struct Ledger { /* private fields */ }Expand description
A per-job checkpoint ledger, backed by a single SQLite file.
The connection is behind a Mutex purely to make Ledger: Sync —
rusqlite::Connection is Send but not Sync (its statement cache uses
unsynchronized interior mutability), and run_job holds a &Ledger
across .await points in a task spawned onto a multi-threaded runtime,
which requires the held reference to be Send, which in turn requires
Ledger: Sync. There is normally only ever one writer (the job that owns
this ledger), so contention is not a real concern; the lock exists to
satisfy the type system’s threading rules, not to arbitrate real
concurrent access.
Implementations§
Source§impl Ledger
impl Ledger
Sourcepub fn open(path: &Path, graph_fingerprint: &str) -> Result<Self>
pub fn open(path: &Path, graph_fingerprint: &str) -> Result<Self>
Open (creating if absent) a job’s ledger at path, ensuring both
tables exist and job_status has its single row.
graph_fingerprint is recorded only when job_status doesn’t exist
yet (a fresh job) — reopening an existing ledger leaves the
originally-recorded fingerprint untouched, since comparing old vs.
new fingerprint is a resume endpoint’s job, not open’s.
Sourcepub fn graph_fingerprint(&self) -> Result<String>
pub fn graph_fingerprint(&self) -> Result<String>
The fingerprint recorded when this job was first submitted — compare against a freshly computed one before resuming.
Sourcepub fn get_completed(&self, node_name: &str) -> Result<Option<Value>>
pub fn get_completed(&self, node_name: &str) -> Result<Option<Value>>
The recorded output of node_name, if it completed successfully.
None for a node that never ran, is still pending, or was skipped.
Sourcepub fn is_skipped(&self, node_name: &str) -> Result<bool>
pub fn is_skipped(&self, node_name: &str) -> Result<bool>
Whether node_name was recorded as skipped (e.g. excluded by a
branch decision).
Sourcepub fn write_completed(&self, node_name: &str, output: &Value) -> Result<()>
pub fn write_completed(&self, node_name: &str, output: &Value) -> Result<()>
Record node_name as completed with output, overwriting any prior
checkpoint for that node.
Sourcepub fn write_skipped(&self, node_name: &str) -> Result<()>
pub fn write_skipped(&self, node_name: &str) -> Result<()>
Record node_name as skipped, overwriting any prior checkpoint for
that node.
Sourcepub fn job_status(&self) -> Result<LedgerJobStatus>
pub fn job_status(&self) -> Result<LedgerJobStatus>
The job’s own terminal status. Running until Ledger::finish is
called.
Auto Trait Implementations§
impl !Freeze for Ledger
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnsafeUnpin for Ledger
impl UnwindSafe for Ledger
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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