pub struct JobContext { /* private fields */ }Expand description
What a job can reach while it runs.
Implementations§
Source§impl JobContext
impl JobContext
Sourcepub fn new(
container: Arc<Container>,
id: impl Into<String>,
queue: impl Into<String>,
attempt: u32,
max_attempts: u32,
) -> Self
pub fn new( container: Arc<Container>, id: impl Into<String>, queue: impl Into<String>, attempt: u32, max_attempts: u32, ) -> Self
Build a context.
Sourcepub fn container(&self) -> &Arc<Container> ⓘ
pub fn container(&self) -> &Arc<Container> ⓘ
The service container, for resolving whatever the job needs.
A job cannot capture its dependencies — it was serialised — so it resolves them here instead.
Sourcepub fn max_attempts(&self) -> u32
pub fn max_attempts(&self) -> u32
How many attempts the job gets in total.
Sourcepub fn is_last_attempt(&self) -> bool
pub fn is_last_attempt(&self) -> bool
Whether this is the last attempt — a job that wants to record a
permanent failure can check this before returning Err.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JobContext
impl RefUnwindSafe for JobContext
impl Send for JobContext
impl Sync for JobContext
impl Unpin for JobContext
impl UnsafeUnpin for JobContext
impl UnwindSafe for JobContext
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
Mutably borrows from an owned value. Read more
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.