pub struct Queue { /* private fields */ }Expand description
The queue handle. Cheap to clone: every clone is the same queue.
Implementations§
Source§impl Queue
impl Queue
Sourcepub fn new(
driver: impl QueueDriver + 'static,
jobs: impl IntoIterator<Item = JobReg>,
services: Services,
options: Options,
) -> Self
pub fn new( driver: impl QueueDriver + 'static, jobs: impl IntoIterator<Item = JobReg>, services: Services, options: Options, ) -> Self
A queue over driver, knowing jobs.
Sourcepub fn inline(
jobs: impl IntoIterator<Item = JobReg>,
services: Services,
) -> Self
pub fn inline( jobs: impl IntoIterator<Item = JobReg>, services: Services, ) -> Self
A queue that runs every job as it is pushed, over no storage: for tests and tools.
pub fn mode(&self) -> Mode
pub fn driver_name(&self) -> &'static str
Sourcepub async fn push_in<T: Job>(
&self,
job: &T,
delay: Duration,
) -> CoreResult<Pushed>
pub async fn push_in<T: Job>( &self, job: &T, delay: Duration, ) -> CoreResult<Pushed>
Pushes job, due after delay.
Sourcepub async fn push_at<T: Job>(
&self,
job: &T,
when: DateTime<Utc>,
) -> CoreResult<Pushed>
pub async fn push_at<T: Job>( &self, job: &T, when: DateTime<Utc>, ) -> CoreResult<Pushed>
Pushes job, due at when.
Sourcepub async fn push_named(
&self,
name: &str,
payload: &Value,
queue: &str,
) -> CoreResult<Pushed>
pub async fn push_named( &self, name: &str, payload: &Value, queue: &str, ) -> CoreResult<Pushed>
Pushes a job by its registered name with a payload already encoded, due now: what a schedule entry does. Refused when no job has the name.
Sourcepub async fn counts(&self) -> CoreResult<Vec<QueueCount>>
pub async fn counts(&self) -> CoreResult<Vec<QueueCount>>
How many jobs each queue holds.
Sourcepub async fn failed(&self) -> CoreResult<Vec<FailedJob>>
pub async fn failed(&self) -> CoreResult<Vec<FailedJob>>
The failed list, newest first.
Sourcepub async fn retry(&self, id: Option<i64>) -> CoreResult<usize>
pub async fn retry(&self, id: Option<i64>) -> CoreResult<usize>
Puts one failed job, or every one, back on its queue.
Sourcepub async fn forget(&self, id: Option<i64>) -> CoreResult<usize>
pub async fn forget(&self, id: Option<i64>) -> CoreResult<usize>
Drops one failed job, or every one.
Sourcepub async fn clear(&self, queue: Option<&str>) -> CoreResult<usize>
pub async fn clear(&self, queue: Option<&str>) -> CoreResult<usize>
Drops every waiting job on queue, or everywhere.
Sourcepub async fn work(
&self,
options: WorkOptions,
stop: Receiver<bool>,
) -> CoreResult<usize>
pub async fn work( &self, options: WorkOptions, stop: Receiver<bool>, ) -> CoreResult<usize>
Runs jobs on this task until stop says so, or as options end it.
Returns how many jobs it processed.
Sourcepub fn spawn_workers(&self, stop: Receiver<bool>) -> Vec<JoinHandle<()>>
pub fn spawn_workers(&self, stop: Receiver<bool>) -> Vec<JoinHandle<()>>
Starts the configured number of workers, each taking from the
configured queues, until stop says so.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Queue
impl !UnwindSafe for Queue
impl Freeze for Queue
impl Send for Queue
impl Sync for Queue
impl Unpin for Queue
impl UnsafeUnpin for Queue
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<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