pub trait TaskStore: Clone + Send {
type Error: Error + Send + Sync;
// Required methods
fn restore_tasks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskMeta>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskMeta>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn store_task<'life0, 'async_trait>(
&'life0 self,
task: TaskMeta,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn store_tasks<'life0, 'async_trait>(
&'life0 self,
tasks: Vec<TaskMeta>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn fetch_pending_task<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
queue: &'life1 str,
runner_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskMeta>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn update_task_execution_status<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
is_success: bool,
last_error: Option<String>,
next_run: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn heartbeat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
runner_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn set_task_stopped<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set_task_removed<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn cleanup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Required Associated Types§
Required Methods§
Sourcefn restore_tasks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn restore_tasks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Restores task states by cleaning up all tasks in a running state and handling their next run times.
This method performs the following actions:
- Cleans up all tasks that are currently in the
Runningstate and may handle theirnext_runfields. - Additional restoration logic can be added within this method.
§Returns
Returns a Result, which is Ok(()) if the operation succeeds; otherwise, it returns the appropriate error.
§Examples
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskMeta>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskMeta>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskMeta>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskMeta>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn store_task<'life0, 'async_trait>(
&'life0 self,
task: TaskMeta,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store_task<'life0, 'async_trait>(
&'life0 self,
task: TaskMeta,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn store_tasks<'life0, 'async_trait>(
&'life0 self,
tasks: Vec<TaskMeta>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store_tasks<'life0, 'async_trait>(
&'life0 self,
tasks: Vec<TaskMeta>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn fetch_pending_task<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
queue: &'life1 str,
runner_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskMeta>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fetch_pending_task<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
queue: &'life1 str,
runner_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskMeta>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetches a pending task based on the queue name and runner ID.
§Arguments
queue: The name of the queue the task belongs to.runner_id: The ID of the runner that will execute the task.
§Returns
Returns an Option<TaskMetaEntity>. If a suitable task is found and updated, it returns Some(TaskMetaEntity), otherwise it returns None.
Sourcefn update_task_execution_status<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
is_success: bool,
last_error: Option<String>,
next_run: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_task_execution_status<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
is_success: bool,
last_error: Option<String>,
next_run: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Updates the execution status of a task.
§Arguments
task_id: The ID of the task to update.is_success: A boolean indicating whether the task succeeded.last_error: An optional string containing the last error message (if applicable).next_run: An optional timestamp for the next scheduled run of the task.
§Returns
Returns Ok(()) if the update is successful; returns an error if the task is not found or if it is stopped or removed.
Sourcefn heartbeat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
runner_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn heartbeat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
runner_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn set_task_stopped<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_task_stopped<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.