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§
Required Methods§
Sourcefn process(
&self,
queue: &SimpleQueue,
job: &Job,
) -> impl Future<Output = Result<JobResult, BoxDynError>> + Send
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§
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.