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§
Sourcefn 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,
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§
Sourcefn is_fatal_error(&self, _: &Error) -> bool
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.
Sourcefn get_next_retry(&self, retries: i64) -> DateTime<Utc>
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.