pub struct Runner<Context> { /* private fields */ }Expand description
The main runner that orchestrates job processing. The core runner responsible for locking and running jobs
Implementations§
Source§impl<Context: Clone + Send + Sync + 'static> Runner<Context>
impl<Context: Clone + Send + Sync + 'static> Runner<Context>
Sourcepub fn new(connection_pool: PgPool, context: Context) -> Self
pub fn new(connection_pool: PgPool, context: Context) -> Self
Create a new runner with the given connection pool and context.
Sourcepub fn register_job_type<J: BackgroundJob<Context = Context>>(self) -> Self
pub fn register_job_type<J: BackgroundJob<Context = Context>>(self) -> Self
Register a new job type for this job runner.
Sourcepub fn configure_default_queue<F>(self, f: F) -> Selfwhere
F: FnOnce(&mut Queue<Context>) -> &Queue<Context>,
pub fn configure_default_queue<F>(self, f: F) -> Selfwhere
F: FnOnce(&mut Queue<Context>) -> &Queue<Context>,
Adjust the configuration of the DEFAULT_QUEUE queue.
Sourcepub fn configure_queue<F>(self, name: &str, f: F) -> Selfwhere
F: FnOnce(&mut Queue<Context>) -> &Queue<Context>,
pub fn configure_queue<F>(self, name: &str, f: F) -> Selfwhere
F: FnOnce(&mut Queue<Context>) -> &Queue<Context>,
Adjust the configuration of a queue. If the queue does not exist, it will be created.
Sourcepub fn shutdown_when_queue_empty(self) -> Self
pub fn shutdown_when_queue_empty(self) -> Self
Set the runner to shut down when the background job queue is empty.
Sourcepub fn start(&self) -> RunHandle
pub fn start(&self) -> RunHandle
Start the background workers.
This returns a RunningRunner which can be used to wait for the workers to shutdown.
Sourcepub async fn check_for_failed_jobs(&self) -> Result<()>
pub async fn check_for_failed_jobs(&self) -> Result<()>
Check if any jobs in the queue have failed.
This function is intended for use in tests and will return an error if any jobs have failed.
Trait Implementations§
Auto Trait Implementations§
impl<Context> !RefUnwindSafe for Runner<Context>
impl<Context> !UnwindSafe for Runner<Context>
impl<Context> Freeze for Runner<Context>where
Context: Freeze,
impl<Context> Send for Runner<Context>where
Context: Send,
impl<Context> Sync for Runner<Context>where
Context: Sync,
impl<Context> Unpin for Runner<Context>where
Context: Unpin,
impl<Context> UnsafeUnpin for Runner<Context>where
Context: 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
impl<T> ErasedDestructor for Twhere
T: 'static,
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>
Converts
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>
Converts
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