Skip to main content

TaskBackend

Trait TaskBackend 

Source
pub trait TaskBackend: Send + Sync {
    // Required methods
    fn enqueue<'life0, 'async_trait>(
        &'life0 self,
        task: Box<dyn Task>,
    ) -> Pin<Box<dyn Future<Output = Result<TaskId, TaskExecutionError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn dequeue<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<TaskId>, TaskExecutionError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_status<'life0, 'async_trait>(
        &'life0 self,
        task_id: TaskId,
    ) -> Pin<Box<dyn Future<Output = Result<TaskStatus, TaskExecutionError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn update_status<'life0, 'async_trait>(
        &'life0 self,
        task_id: TaskId,
        status: TaskStatus,
    ) -> Pin<Box<dyn Future<Output = Result<(), TaskExecutionError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_task_data<'life0, 'async_trait>(
        &'life0 self,
        task_id: TaskId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<SerializedTask>, TaskExecutionError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn backend_name(&self) -> &str;
}
Available on crate feature tasks and non-WebAssembly only.
Expand description

Trait for task queue backends that handle enqueueing, dequeueing, and status tracking.

Required Methods§

Source

fn enqueue<'life0, 'async_trait>( &'life0 self, task: Box<dyn Task>, ) -> Pin<Box<dyn Future<Output = Result<TaskId, TaskExecutionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Enqueues a task and returns its assigned ID.

Source

fn dequeue<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<TaskId>, TaskExecutionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Dequeues the next available task ID, if any.

Source

fn get_status<'life0, 'async_trait>( &'life0 self, task_id: TaskId, ) -> Pin<Box<dyn Future<Output = Result<TaskStatus, TaskExecutionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Retrieves the current status of a task by its ID.

Source

fn update_status<'life0, 'async_trait>( &'life0 self, task_id: TaskId, status: TaskStatus, ) -> Pin<Box<dyn Future<Output = Result<(), TaskExecutionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Updates the status of a task.

Source

fn get_task_data<'life0, 'async_trait>( &'life0 self, task_id: TaskId, ) -> Pin<Box<dyn Future<Output = Result<Option<SerializedTask>, TaskExecutionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Get serialized task data by task ID

Returns the task data if found, None otherwise.

Source

fn backend_name(&self) -> &str

Returns the name of this backend implementation.

Implementors§