Skip to main content

Handler

Trait Handler 

Source
pub trait Handler: Send + Sync {
    const QUEUE: &'static str;

    // Required method
    fn process(
        &self,
        queue: &SimpleQueue,
        job: &Job,
    ) -> impl Future<Output = Result<JobResult, BoxDynError>> + Send;

    // Provided method
    fn queue(&self) -> &'static str { ... }
}
Expand description

Required trait for job handlers

Required Associated Constants§

Source

const QUEUE: &'static str

Required Methods§

Source

fn process( &self, queue: &SimpleQueue, job: &Job, ) -> impl Future<Output = Result<JobResult, BoxDynError>> + Send

Job processing function.

While it’s running, heartbeat will be sent to indicate that the job is alive.

It contains reference to SimpleQueue (for interacting with the queue) and the Job given for processing.

Should return JobResult indicating success or failure,

Error result is considered a failure and will be retried, however it is expected that handler will decide what to do with the error.

Provided Methods§

Source

fn queue(&self) -> &'static str

Returns the queue name this handler is associated with.

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.

Implementors§