pub struct NewJob { /* private fields */ }Expand description
A job to queue: its type, its arguments, and when and how it runs.
Implementations§
Source§impl NewJob
impl NewJob
Sourcepub fn new(name: impl Into<String>, args: Value) -> Self
pub fn new(name: impl Into<String>, args: Value) -> Self
A job for the handler named name, ready now, with the queue’s limit on
tries and priority zero.
Sourcepub fn unique(self, key: impl Into<String>) -> Self
pub fn unique(self, key: impl Into<String>) -> Self
Queue this job only if no job of its name, tenant, and key is queued or
running: otherwise queuing it adds nothing and answers the id of the one
there, whose arguments, priority, and time stand. The key is a code, at most
MAX_REASON_CHARS characters with no line breaks, such as "sync:42", and
is kept on the job’s row, so it holds no secret or personal data. Enqueuing
refuses any other key with Error::NotACode.
Sourcepub fn tenant(self, tenant: impl Into<String>) -> Self
pub fn tenant(self, tenant: impl Into<String>) -> Self
Run this job for tenant, the id an auth crate’s Tenant gives, which its
handler receives beside the arguments, so that it can open its own tenant
transaction. Only a handler registered with Queue::handle_with_tenant runs
it. Enqueuing refuses an id that is not a tenant id, with
Error::NotATenant.
Sourcepub const fn timeout(self, limit: Duration) -> Self
pub const fn timeout(self, limit: Duration) -> Self
Stop a run of this job past limit, and count it as failed with the reason.
A job has no time limit unless it is given one.
Sourcepub const fn max_attempts(self, max_attempts: Option<i32>) -> Self
pub const fn max_attempts(self, max_attempts: Option<i32>) -> Self
Tries this job gets, including the first, or the queue’s when None.
Sourcepub const fn priority(self, priority: i16) -> Self
pub const fn priority(self, priority: i16) -> Self
Run ahead of ready jobs with a lower priority. Zero by default, and may be negative.
Sourcepub const fn run_in(self, delay: Duration) -> Self
pub const fn run_in(self, delay: Duration) -> Self
Run no sooner than delay from now, on the database’s clock.
Sourcepub fn unique_key(&self) -> Option<&str>
pub fn unique_key(&self) -> Option<&str>
The key this job is unique by, if any.
Trait Implementations§
Auto Trait Implementations§
impl Forget for NewJob
impl Freeze for NewJob
impl Move for NewJob
impl RefUnwindSafe for NewJob
impl Send for NewJob
impl Sync for NewJob
impl Unpin for NewJob
impl UnsafeUnpin for NewJob
impl UnwindSafe for NewJob
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