Skip to main content

TaskStore

Trait TaskStore 

Source
pub trait TaskStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn put(
        &self,
        task: StoredTask,
        expected: Option<u64>,
    ) -> impl Future<Output = Result<bool>> + Send;
    fn get(
        &self,
        id: &str,
    ) -> impl Future<Output = Result<Option<StoredTask>>> + Send;
}
Expand description

Keeps task state between the call that started a task and the polls that read it.

Required Methods§

Source

fn put( &self, task: StoredTask, expected: Option<u64>, ) -> impl Future<Output = Result<bool>> + Send

Writes task only if the stored task with its id is at version expected (None: no task with that id exists), atomically, and returns whether it wrote: false means another writer got there first and the kit reads again. In SQL, an insert or an UPDATE ... WHERE version = $expected. Keeps the task for at least TASK_TTL after task.updated_at.

Source

fn get( &self, id: &str, ) -> impl Future<Output = Result<Option<StoredTask>>> + Send

The task with id, if it is still kept. The kit checks the space.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§