pub struct JobCtx {
pub id: String,
pub queue: String,
pub job_type: String,
pub priority: Priority,
pub attempt: u32,
pub max_attempts: u32,
pub enqueued_at: SystemTime,
pub scheduled_at: Option<SystemTime>,
pub custom: HashMap<String, Primitive>,
pub trace_context: Option<TraceContext>,
pub lease_expires_at: SystemTime,
/* private fields */
}Expand description
Everything about a reserved job except its payload: identity, delivery metadata, and the handle needed to manage its lease.
A handler receives this as Arc<JobCtx> alongside the payload. It also
carries an internal lease handle, which is why extend
can be called directly on it.
Fields§
§id: StringServer-assigned job id (a UUID).
queue: StringThe queue this job was reserved from. Useful when a worker reserves from several queues and needs to tell which one each job came from.
job_type: StringThe job type, used to route to a handler.
priority: PriorityThe job’s effective priority.
attempt: u32Which delivery attempt this is, starting at 1 and incremented on each
redelivery.
max_attempts: u32The maximum attempts before the job is dead-lettered.
enqueued_at: SystemTimeWhen the producer enqueued the job.
scheduled_at: Option<SystemTime>When the producer scheduled the job to run, if it was
delayed; None for a job that was
available immediately.
custom: HashMap<String, Primitive>Custom metadata the producer attached.
trace_context: Option<TraceContext>The producer’s trace context, if any and if it was well-formed.
lease_expires_at: SystemTimeWhen the current lease expires. The job must be acked, nacked, or extended before this, or it will be redelivered.
Implementations§
Source§impl JobCtx
impl JobCtx
Sourcepub async fn extend(
&self,
extension: Duration,
) -> Result<SystemTime, LeaseError>
pub async fn extend( &self, extension: Duration, ) -> Result<SystemTime, LeaseError>
Extends this job’s lease by extension, measured from now, and returns
the new expiry.
Use this from inside a handler that needs more time than the original
lease allowed. A Worker configured with
with_auto_extend does this for you.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for JobCtx
impl !RefUnwindSafe for JobCtx
impl !UnwindSafe for JobCtx
impl Send for JobCtx
impl Sync for JobCtx
impl Unpin for JobCtx
impl UnsafeUnpin for JobCtx
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request