Skip to main content

JobHandler

Trait JobHandler 

Source
pub trait JobHandler:
    Send
    + Sync
    + 'static {
    type Job: Job;

    // Required method
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        job: Self::Job,
        ctx: JobContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Processes jobs of one type. Register with crate::WorkerBuilder::handler.

Required Associated Types§

Source

type Job: Job

The one job type this handler processes.

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, job: Self::Job, ctx: JobContext, ) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process one job. Returning Err hands control to the retry policy.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<J, F, Fut> JobHandler for FnHandler<J, F>
where J: Job, F: Fn(J, JobContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<(), JobError>> + Send + 'static,

Source§

type Job = J