[][src]Trait izta::job::Job

pub trait Job {
    type R: Serialize + DeserializeOwned;
    type E: Serialize + DeserializeOwned;

    const UUID: &'static str;
    const MAX_ATTEMPTS: usize;

    fn run(&self) -> Result<Self::R, Self::E>;

    fn run_task(&self, task: &Task) -> RunTaskResult { ... }
}

Associated Types

type R: Serialize + DeserializeOwned

Result type produced by the run() method. Use () for jobs that are only executed for their side-effects.

type E: Serialize + DeserializeOwned

Error type produced by the run() method. Use () for jobs that always succeed.

Loading content...

Associated Constants

const UUID: &'static str

Each job must have a unique UUID. If any aspect of a job definition is changed, it's a good idea to update this.

const MAX_ATTEMPTS: usize

Maximum number of attempts (including first run) to execute job. Jobs that panic are never retried. Reruns are scheduled to occur at fail time + 5 seconds + attempts^4 seconds. Set to 1 if retry logic isn't desired.

Loading content...

Required methods

fn run(&self) -> Result<Self::R, Self::E>

Executed when an associated task is de-queued and run

Loading content...

Provided methods

fn run_task(&self, task: &Task) -> RunTaskResult

Execute associated Task. Not meant to be re-implemented or called manually. The only caller should be the process_jobs! macro.

Loading content...

Implementors

Loading content...