pub struct QueuedJob {
pub name: String,
pub payload: Json,
pub queue: String,
pub max_tries: u32,
pub retry_after: Duration,
pub delay: Duration,
pub chain: Option<String>,
pub then: Vec<QueuedJob>,
}Expand description
A job as it is stored: a name, a payload, and the policy for running it.
Everything past the dispatch call deals in this rather than in a concrete
type, which is what keeps the Queue trait dyn-compatible.
Fields§
§name: String§payload: Json§queue: String§max_tries: u32§retry_after: Duration§delay: DurationHow long after being pushed the job becomes visible to a worker.
chain: Option<String>The chain this job is a step of, when it is one. See crate::Chain.
then: Vec<QueuedJob>The steps to run after this one succeeds, in order. Empty for a job that stands alone.
Implementations§
Source§impl QueuedJob
impl QueuedJob
Sourcepub fn new(name: impl Into<String>, payload: Json) -> Self
pub fn new(name: impl Into<String>, payload: Json) -> Self
An envelope built by hand, for a caller that has a name and a payload but no Rust type — a job pushed by another service, say.
Sourcepub fn stored_payload(&self) -> Json
pub fn stored_payload(&self) -> Json
The payload as it is stored, with the chain folded in.
A chain rides inside the payload column rather than in columns of its
own, so a jobs table created by 0.7 needs no migration to carry one.
A job with no chain is stored exactly as before, so every row already in
a table reads back unchanged. The keys start with $ so they cannot
collide with a payload’s own.
Sourcepub fn with_stored_payload(self, stored: Json) -> QueuedJob
pub fn with_stored_payload(self, stored: Json) -> QueuedJob
The inverse of stored_payload: a job read back
from storage, with the chain unfolded and the payload restored.