Skip to main content

Worker

Trait Worker 

Source
pub trait Worker<Args: Send + Sync>: Send + Sync {
    type Error: Error + Send + Sync;

    // Required method
    fn process<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        job: &'life1 Args,
        ctx: &'life2 JobContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn max_retries(&self, _job: &Args) -> u32 { ... }
    fn retry_delay(&self, _job: &Args, retries: u32) -> u64 { ... }
    fn cron_schedule() -> Option<String>
       where Self: Sized { ... }
    fn cron_queue_config() -> Option<QueueConfig>
       where Self: Sized { ... }
    fn to_config() -> WorkerConfigKind
       where Self: Sized,
             Args: Job { ... }
}

Required Associated Types§

Required Methods§

Source

fn process<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, job: &'life1 Args, ctx: &'life2 JobContext, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Provided Methods§

Source

fn max_retries(&self, _job: &Args) -> u32

Source

fn retry_delay(&self, _job: &Args, retries: u32) -> u64

Source

fn cron_schedule() -> Option<String>
where Self: Sized,

6 part cron schedule: “* * * * * *”

Source

fn cron_queue_config() -> Option<QueueConfig>
where Self: Sized,

Source

fn to_config() -> WorkerConfigKind
where Self: Sized, Args: Job,

Implementors§