Trait Job

Source
pub trait Job:
    Send
    + Sync
    + Serialize
    + Deserialize {
    // Required method
    fn run<'life0, 'async_trait>(
        &'life0 mut self,
        queue: Arc<AppQueue>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn is_fatal_error(&self, _: &Error) -> bool { ... }
    fn get_next_retry(&self, retries: i64) -> DateTime<Utc> { ... }
}
Expand description

Queued Job interface

Required Methods§

Source

fn run<'life0, 'async_trait>( &'life0 mut self, queue: Arc<AppQueue>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempt to run the job.

§Errors

In addition to any errors caused by the job itself, the job may return an error to indicate that the job should be requeued.

Provided Methods§

Source

fn is_fatal_error(&self, _: &Error) -> bool

Check if an error is fatal.

Jobs that return a fatal error will not be requeued.

The default implementation treats all errors as non-fatal.

Source

fn get_next_retry(&self, retries: i64) -> DateTime<Utc>

Calculates the next time the job should be retried.

It receives the number of times the job has already been retried.

The default behavior is an exponential backoff, with a maximum retry period of 10 minutes.

Trait Implementations§

Source§

impl<'typetag> Serialize for dyn Job + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Job + Send + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Job + Send + Sync + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Job + Sync + 'typetag

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Implementors§