[][src]Trait actix_taskqueue::worker::QueueConsumer

pub trait QueueConsumer<T: Default + Sized + Unpin + 'static, W> {
#[must_use]    fn execute<'life0, 'async_trait>(
        &'life0 self,
        task: T
    ) -> Pin<Box<dyn Future<Output = Result<W, WorkerExecuteError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_queue(&self) -> Addr<TaskQueue<T>>;
fn retry(&self, task: T) -> T;
fn drop(&self, task: T);
fn result(&self, result: W); }

QueueConsumer Trait

This is the trait that should be implemented in your application for the pair of Task and TaskResult data structures.

This trait define the expected behavior of the task queue.

Required methods

#[must_use]fn execute<'life0, 'async_trait>(
    &'life0 self,
    task: T
) -> Pin<Box<dyn Future<Output = Result<W, WorkerExecuteError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

This function takes a task description, and do the work related to that task. It should return a Result<TaskResult, WorkerExecuteError>.

fn get_queue(&self) -> Addr<TaskQueue<T>>

This function returns the TaskQueue from the System Registry for the specific task type that you're having.

fn retry(&self, task: T) -> T

This function return the new Task object that will be pushed back to the TaskQueue to be retried.

fn drop(&self, task: T)

This function will be called when a Task is dropped from the queue in case it's not retryable anymore.

fn result(&self, result: W)

This function will be called when a Task finished successfully. The result parameter is the returned result of the Task.

Loading content...

Implementors

Loading content...