#[non_exhaustive]pub struct JobOptions {
pub queue: Option<&'static str>,
pub tries: Option<u32>,
pub max_errors: Option<u32>,
pub backoff: Vec<ExactDuration>,
pub timeout: Option<ExactDuration>,
pub retry_for: Option<ExactDuration>,
pub debounce_for: Option<ExactDuration>,
pub max_wait: Option<ExactDuration>,
pub fail_when_missing_models: bool,
}Expand description
A job’s queue, retries, and timeout, from the options of #[job(..)].
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.queue: Option<&'static str>The queue the job joins when its dispatch doesn’t name another.
tries: Option<u32>How many times the job may run, counting releases, or None for the worker’s default.
The worker ignores this limit when retry_for is set.
max_errors: Option<u32>How many of the job’s runs may fail before it fails for good, or None for no limit
other than tries.
A run that stops its worker counts as a failed run. The worker counts errors in the default cache store for a day. When the worker can’t reach the cache, it doesn’t count the error.
backoff: Vec<ExactDuration>How long to wait before each retry, in order. The last delay repeats once the list runs out.
timeout: Option<ExactDuration>How long one attempt may run, or None for the worker’s default.
retry_for: Option<ExactDuration>How long after dispatch the job may still be retried, or None for no limit.
debounce_for: Option<ExactDuration>How long each dispatch waits before it may run, or None to not debounce the job.
Of the waiting dispatches with the same debounce ID, only the latest runs.
max_wait: Option<ExactDuration>How long the first of a debounced job’s waiting dispatches may wait before a dispatch runs
without waiting, or None for no limit. The queue ignores this limit without
debounce_for.
fail_when_missing_models: boolWhether to fail the job for good, rather than delete it, when the row of one of its models is gone.
Implementations§
Source§impl JobOptions
impl JobOptions
Sourcepub fn new() -> JobOptions
pub fn new() -> JobOptions
Create options with nothing set, so the worker’s defaults apply.
Sourcepub const fn queue(self, queue: &'static str) -> JobOptions
pub const fn queue(self, queue: &'static str) -> JobOptions
Join this queue when the dispatch doesn’t name another.
Sourcepub fn tries(self, tries: u32) -> JobOptions
pub fn tries(self, tries: u32) -> JobOptions
Run the job at most this many times, counting releases. The value must be at least one.
Sourcepub fn max_errors(self, errors: u32) -> JobOptions
pub fn max_errors(self, errors: u32) -> JobOptions
Fail the job for good once this many runs have failed. The value must be at least one.
Sourcepub fn backoff(
self,
delays: impl IntoIterator<Item = impl Into<ZonedDateTimeArithmetic>>,
) -> JobOptions
pub fn backoff( self, delays: impl IntoIterator<Item = impl Into<ZonedDateTimeArithmetic>>, ) -> JobOptions
Wait this long before each retry, in order.
Sourcepub fn timeout(self, timeout: impl Into<ZonedDateTimeArithmetic>) -> JobOptions
pub fn timeout(self, timeout: impl Into<ZonedDateTimeArithmetic>) -> JobOptions
Stop an attempt that runs longer than this.
Sourcepub fn retry_for(
self,
lifetime: impl Into<ZonedDateTimeArithmetic>,
) -> JobOptions
pub fn retry_for( self, lifetime: impl Into<ZonedDateTimeArithmetic>, ) -> JobOptions
Keep retrying the job for at most this long after dispatch, however many runs that takes.
Sourcepub fn debounce_for(
self,
delay: impl Into<ZonedDateTimeArithmetic>,
) -> JobOptions
pub fn debounce_for( self, delay: impl Into<ZonedDateTimeArithmetic>, ) -> JobOptions
Hold each dispatch this long, and run only the latest dispatch with the same debounce ID.
Sourcepub fn max_wait(self, wait: impl Into<ZonedDateTimeArithmetic>) -> JobOptions
pub fn max_wait(self, wait: impl Into<ZonedDateTimeArithmetic>) -> JobOptions
Run a dispatch immediately once the first waiting dispatch has waited this long.
Sourcepub const fn fail_when_missing_models(self) -> JobOptions
pub const fn fail_when_missing_models(self) -> JobOptions
Fail the job for good with a MissingModels error, rather than
delete it, when the row of one of its models is gone.
Without this option, the worker deletes the job without running it, the jobs after it in a chain don’t run, and a batch counts them as skipped.
Trait Implementations§
Source§impl Clone for JobOptions
impl Clone for JobOptions
Source§fn clone(&self) -> JobOptions
fn clone(&self) -> JobOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JobOptions
impl Debug for JobOptions
Source§impl Default for JobOptions
impl Default for JobOptions
Source§fn default() -> JobOptions
fn default() -> JobOptions
impl Eq for JobOptions
Source§impl PartialEq for JobOptions
impl PartialEq for JobOptions
impl StructuralPartialEq for JobOptions
Auto Trait Implementations§
impl Forget for JobOptions
impl Freeze for JobOptions
impl Move for JobOptions
impl RefUnwindSafe for JobOptions
impl Send for JobOptions
impl Sync for JobOptionswhere
RawVecInner: Sync,
impl Unpin for JobOptions
impl UnsafeUnpin for JobOptionswhere
&'static str: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<ExactDuration>: UnsafeUnpin,
impl UnwindSafe for JobOptions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
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> 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