pub struct JobQueue<J> { /* private fields */ }Expand description
The queue; cheap to clone, all clones are the same queue
Implementations§
Source§impl<J> JobQueue<J>
impl<J> JobQueue<J>
Sourcepub fn new(config: QueueConfig) -> Self
pub fn new(config: QueueConfig) -> Self
An empty queue, or the one saved in persist_to’s file. Jobs that were
running when the file was written are pending again.
pub fn enqueue_with(&self, payload: J, options: EnqueueOptions) -> Enqueued
Sourcepub fn dead_jobs(&self) -> Vec<JobRecord<J>>
pub fn dead_jobs(&self) -> Vec<JobRecord<J>>
Jobs that ran out of attempts (or failed fatally), oldest first
Sourcepub fn retry_dead(&self, id: JobId) -> bool
pub fn retry_dead(&self, id: JobId) -> bool
Give a dead job a fresh start; false if there is no such dead job
Sourcepub fn delete_dead(&self, id: JobId) -> bool
pub fn delete_dead(&self, id: JobId) -> bool
Remove a dead job for good; false if there is no such dead job
Sourcepub async fn run<F, Fut>(&self, shutdown: Shutdown, workers: usize, handler: F)
pub async fn run<F, Fut>(&self, shutdown: Shutdown, workers: usize, handler: F)
Run workers workers until shutdown fires; returns when the jobs that
were in flight have finished and the queue has been saved.
Typically called from App::background.
A handler that panics counts as a failed attempt.
Sourcepub async fn persist_now(&self)
pub async fn persist_now(&self)
Write the queue to its file now (also done automatically while running)
Trait Implementations§
Auto Trait Implementations§
impl<J> !RefUnwindSafe for JobQueue<J>
impl<J> !UnwindSafe for JobQueue<J>
impl<J> Freeze for JobQueue<J>
impl<J> Send for JobQueue<J>
impl<J> Sync for JobQueue<J>
impl<J> Unpin for JobQueue<J>
impl<J> UnsafeUnpin for JobQueue<J>where
Arc<Inner<J>>: UnsafeUnpin,
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