Skip to main content

StepJournal

Trait StepJournal 

Source
pub trait StepJournal:
    Send
    + Sync
    + 'static {
    // Required methods
    fn load<'a>(
        &'a self,
        key: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<JournalEntry>, JournalError>> + Send + 'a>>;
    fn save<'a>(
        &'a self,
        key: &'a str,
        entry: &'a JournalEntry,
    ) -> Pin<Box<dyn Future<Output = Result<(), JournalError>> + Send + 'a>>;
    fn clear<'a>(
        &'a self,
        key: &'a str,
        revision: u64,
    ) -> Pin<Box<dyn Future<Output = Result<(), JournalError>> + Send + 'a>>;
    fn sweep(
        &self,
        completed_before_ms: i64,
        unfinished_before_ms: i64,
    ) -> Pin<Box<dyn Future<Output = Result<u64, JournalError>> + Send + '_>>;
    fn runs_of<'a>(
        &'a self,
        principal: &'a str,
        tenant: Option<&'a str>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RunSummary>, JournalError>> + Send + 'a>>;
    fn erase<'a>(
        &'a self,
        principal: &'a str,
        tenant: Option<&'a str>,
    ) -> Pin<Box<dyn Future<Output = Result<u64, JournalError>> + Send + 'a>>;
}
Available on crate feature tool-loop only.
Expand description

Where a run’s checkpoints are kept.

An implementation must make save and clear atomic compare-and-sets on the revision: that is the fence that keeps a replica which lost its claim from overwriting, or deleting, a newer run’s progress.

Required Methods§

Source

fn load<'a>( &'a self, key: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<JournalEntry>, JournalError>> + Send + 'a>>

The entry stored under key, if there is one.

Source

fn save<'a>( &'a self, key: &'a str, entry: &'a JournalEntry, ) -> Pin<Box<dyn Future<Output = Result<(), JournalError>> + Send + 'a>>

Stores entry under key only if the revision stored is entry.revision - 1 (none stored counts as 0), and returns JournalError::Conflict otherwise.

Source

fn clear<'a>( &'a self, key: &'a str, revision: u64, ) -> Pin<Box<dyn Future<Output = Result<(), JournalError>> + Send + 'a>>

Deletes the entry under key only if its revision is revision: JournalError::Conflict when another revision is stored, Ok when none is. A stale run’s delete cannot remove a newer run’s entry.

Source

fn sweep( &self, completed_before_ms: i64, unfinished_before_ms: i64, ) -> Pin<Box<dyn Future<Output = Result<u64, JournalError>> + Send + '_>>

Deletes completed runs last written before completed_before_ms and unfinished ones last written before unfinished_before_ms (Unix milliseconds); returns how many went. A run still going when its entry is swept is refused its next write (JournalError::Conflict: none stored takes only revision 1), so the unfinished cutoff must be well past the longest run and its approvals.

Source

fn runs_of<'a>( &'a self, principal: &'a str, tenant: Option<&'a str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<RunSummary>, JournalError>> + Send + 'a>>

Every run of principal, in tenant when one is given, without its content: for an access request, and to know what erase would delete.

Source

fn erase<'a>( &'a self, principal: &'a str, tenant: Option<&'a str>, ) -> Pin<Box<dyn Future<Output = Result<u64, JournalError>> + Send + 'a>>

Deletes every run of principal, in tenant when one is given; returns how many went. What a person’s erasure must call for the journal: the task store’s and the audit log’s do not reach it. A person named only inside a run’s content (a tool argument, a message) is not found by this.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§