pub trait Job:
Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static {
const NAME: &'static str;
// Required method
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
cx: &'life1 JobCx,
) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn queue(&self) -> String { ... }
fn tries(&self) -> u32 { ... }
fn backoff(&self, attempt: u32) -> Duration { ... }
fn timeout(&self) -> Option<Duration> { ... }
fn retry_until(&self) -> Option<DateTime<Utc>> { ... }
fn unique_key(&self) -> Option<String> { ... }
}Expand description
Work to run later. The struct is the payload: whatever it carries is stored as JSON and read back by the worker.
Required Associated Constants§
Required Methods§
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
cx: &'life1 JobCx,
) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Provided Methods§
Sourcefn queue(&self) -> String
fn queue(&self) -> String
The queue the job lands on. DEFAULT_QUEUE unless overridden.
Sourcefn tries(&self) -> u32
fn tries(&self) -> u32
How many attempts before the job fails; 0 means as many as the
retry window allows. Three unless overridden.
Sourcefn backoff(&self, attempt: u32) -> Duration
fn backoff(&self, attempt: u32) -> Duration
How long to wait before attempt attempt + 1, after attempt
attempt failed. Ten seconds, doubling each time, unless overridden.
Sourcefn timeout(&self) -> Option<Duration>
fn timeout(&self) -> Option<Duration>
How long one attempt may run. A minute unless overridden; None
means no limit.
Sourcefn retry_until(&self) -> Option<DateTime<Utc>>
fn retry_until(&self) -> Option<DateTime<Utc>>
Keep retrying until this moment, whatever tries says. None
unless overridden.
Sourcefn unique_key(&self) -> Option<String>
fn unique_key(&self) -> Option<String>
A key no two pending jobs may share: a push while one with the same
key waits is dropped. None unless overridden.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".