Trait Job

Source
pub trait Job:
    Send
    + Sync
    + Serialize
    + DeserializeOwned {
    // Required methods
    fn execute<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = JobResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn job_type(&self) -> &'static str;

    // Provided methods
    fn max_retries(&self) -> u32 { ... }
    fn retry_delay(&self, attempt: u32) -> Duration { ... }
    fn timeout(&self) -> Duration { ... }
}
Expand description

Core trait that all jobs must implement

Required Methods§

Source

fn execute<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = JobResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the job

Source

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

Get the job type identifier

Provided Methods§

Source

fn max_retries(&self) -> u32

Get maximum number of retry attempts (default: 3)

Source

fn retry_delay(&self, attempt: u32) -> Duration

Get retry delay (default: exponential backoff starting at 1 second)

Source

fn timeout(&self) -> Duration

Get job timeout (default: 5 minutes)

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§