Trait background_jobs::Job

source ·
pub trait Job<S = ()>: Serialize + DeserializeOwnedwhere
    S: 'static + Clone + Send + Sync,
{ fn run(
        self,
        state: S
    ) -> Box<dyn Future<Error = Error, Item = ()> + Send + 'static, Global>; fn queue(&self) -> Option<&str> { ... } fn max_retries(&self) -> Option<MaxRetries> { ... } fn backoff_strategy(&self) -> Option<Backoff> { ... } }
Expand description

The Job trait defines parameters pertaining to an instance of background job

Required Methods§

Users of this library must define what it means to run a job.

This should contain all the logic needed to complete a job. If that means queuing more jobs, sending an email, shelling out (don’t shell out), or doing otherwise lengthy processes, that logic should all be called from inside this method.

The state passed into this job is initialized at the start of the application. The state argument could be useful for containing a hook into something like r2d2, or the address of an actor in an actix-based system.

Provided Methods§

If this job should not use the default queue for its processor, this can be overridden in user-code.

Jobs will only be processed by processors that are registered, and if a queue is supplied here that is not associated with a valid processor for this job, it will never be processed.

If this job should not use the default maximum retry count for its processor, this can be overridden in user-code.

If this job should not use the default backoff strategy for its processor, this can be overridden in user-code.

Implementations on Foreign Types§

Implementors§