Skip to main content

Checkpointer

Trait Checkpointer 

Source
pub trait Checkpointer: Send + Sync {
    // Required methods
    fn save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        checkpoint: &'life1 Checkpoint,
    ) -> Pin<Box<dyn Future<Output = Result<String, GraphError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint>, GraphError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn load_by_id<'life0, 'life1, 'async_trait>(
        &'life0 self,
        checkpoint_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint>, GraphError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint>, GraphError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), GraphError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn prune<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 str,
        policy: &'life2 RetentionPolicy,
    ) -> Pin<Box<dyn Future<Output = Result<usize, GraphError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn list_page<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 str,
        before: Option<u64>,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint>, GraphError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Available on crate feature graph only.
Expand description

Stores graph checkpoints. See the module documentation for the contract.

Required Methods§

Source

fn save<'life0, 'life1, 'async_trait>( &'life0 self, checkpoint: &'life1 Checkpoint, ) -> Pin<Box<dyn Future<Output = Result<String, GraphError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Saves a checkpoint and returns its ID.

§Errors

Returns GraphError::CheckpointConflict when the thread already holds an equal or higher version, and an error when the ID is already stored or the backend cannot be written.

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint>, GraphError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Loads the newest checkpoint of a thread: the one with the highest version.

Source

fn load_by_id<'life0, 'life1, 'async_trait>( &'life0 self, checkpoint_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint>, GraphError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Loads a checkpoint by ID.

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint>, GraphError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Lists a thread’s checkpoints, oldest version first.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), GraphError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Deletes every checkpoint of a thread, its open pauses included.

Deleting a thread that holds no checkpoints is a no-op. The thread’s versions start afresh afterwards.

§Errors

Returns an error when the backend cannot be written.

Source

fn prune<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, thread_id: &'life1 str, policy: &'life2 RetentionPolicy, ) -> Pin<Box<dyn Future<Output = Result<usize, GraphError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Removes the checkpoints a retention policy discards from one thread.

Backends select with RetentionPolicy::expired, so nothing a resume still needs (needed_to_resume) is removed. Returns how many were removed.

§Errors

Returns an error when the backend cannot be read or written.

Provided Methods§

Source

fn list_page<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 str, before: Option<u64>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint>, GraphError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Lists at most limit of a thread’s checkpoints, newest version first, starting below version before when given.

Pass the version of the last checkpoint of one page as before to read the next. The default filters list; backends override it to read one page only.

§Errors

Returns an error when the backend cannot be read.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§