#[non_exhaustive]pub struct Job {
pub id: JobId,
pub queue: String,
pub payload: Bytes,
pub attempt: u32,
pub max_attempts: u32,
pub leased_until: SystemTime,
pub trace_context: Option<TraceContext>,
pub cancellation: JobCancellation,
pub priority: Priority,
pub concurrency_key: Option<String>,
/* private fields */
}Expand description
A leased unit of work returned by Queue::dequeue.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: JobIdStable id (also the natural idempotency key for consumers).
queue: StringSource queue.
payload: BytesOpaque payload.
attempt: u321 on first delivery, N on the Nth.
max_attempts: u32Deliveries before dead-lettering.
leased_until: SystemTimeLease deadline; refresh with Queue::heartbeat before it passes.
trace_context: Option<TraceContext>Reserved cross-process W3C propagation metadata, never mixed into payload bytes.
cancellation: JobCancellationCooperative application-cancellation signal.
priority: Priority§concurrency_key: Option<String>Implementations§
Source§impl Job
impl Job
Sourcepub fn new(
id: JobId,
queue: String,
payload: Bytes,
attempt: u32,
max_attempts: u32,
leased_until: SystemTime,
lease_token: Uuid,
) -> Self
pub fn new( id: JobId, queue: String, payload: Bytes, attempt: u32, max_attempts: u32, leased_until: SystemTime, lease_token: Uuid, ) -> Self
Construct a leased job. For backend implementors: a backend mints this from a
claimed row, supplying the per-lease fence lease_token that ack/nack/
heartbeat later check via Job::lease_token. App code never calls this; it
receives Jobs from Queue::dequeue.
Sourcepub fn with_trace_context(self, trace_context: Option<TraceContext>) -> Self
pub fn with_trace_context(self, trace_context: Option<TraceContext>) -> Self
Attach stored propagation metadata when a backend materializes the lease.
pub fn with_scheduling( self, priority: Priority, concurrency_key: Option<String>, ) -> Self
Sourcepub fn lease_token(&self) -> Uuid
pub fn lease_token(&self) -> Uuid
The per-lease fence token. For backend implementors: ack/nack/heartbeat
must only mutate the row while it still carries this token, so a stale worker’s
calls become no-ops / Precondition.
Sourcepub fn payload_json<T: DeserializeOwned>(&self) -> Result<T>
pub fn payload_json<T: DeserializeOwned>(&self) -> Result<T>
Deserialize the payload from JSON. A decode failure is
ForgeError::Invalid; the payload is caller data, not a backend error.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Job
impl RefUnwindSafe for Job
impl Send for Job
impl Sync for Job
impl Unpin for Job
impl UnsafeUnpin for Job
impl UnwindSafe for Job
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more