pub struct JobRegistry { /* private fields */ }
Expand description
Stores a mapping from job name to job. Can be used to construct a job runner.
Implementations§
Source§impl JobRegistry
impl JobRegistry
Sourcepub fn new(jobs: &[&'static NamedJob]) -> Self
pub fn new(jobs: &[&'static NamedJob]) -> Self
Construct a new job registry from the provided job list.
Sourcepub fn set_error_handler(
&mut self,
error_handler: impl Fn(&str, Box<dyn Error + Send + 'static>) + Send + Sync + 'static,
) -> &mut Self
pub fn set_error_handler( &mut self, error_handler: impl Fn(&str, Box<dyn Error + Send + 'static>) + Send + Sync + 'static, ) -> &mut Self
Set a function to be called whenever a job returns an error.
Sourcepub fn set_context<C: Clone + Send + Sync + 'static>(
&mut self,
context: C,
) -> &mut Self
pub fn set_context<C: Clone + Send + Sync + 'static>( &mut self, context: C, ) -> &mut Self
Provide context for the jobs.
Sourcepub fn context<C: Clone + Send + Sync + 'static>(&self) -> C
pub fn context<C: Clone + Send + Sync + 'static>(&self) -> C
Access job context. Will panic if context with this type has not been provided.
Sourcepub fn resolve_job(&self, name: &str) -> Option<&'static NamedJob>
pub fn resolve_job(&self, name: &str) -> Option<&'static NamedJob>
Look-up a job by name.
Sourcepub fn default_error_handler(name: &str, error: Box<dyn Error + Send + 'static>)
pub fn default_error_handler(name: &str, error: Box<dyn Error + Send + 'static>)
The default error handler implementation, which simply logs the error.
Sourcepub fn runner(self, pool: &Pool<Postgres>) -> JobRunnerOptions
pub fn runner(self, pool: &Pool<Postgres>) -> JobRunnerOptions
Construct a job runner from this registry and the provided connection pool.
Auto Trait Implementations§
impl Freeze for JobRegistry
impl !RefUnwindSafe for JobRegistry
impl Send for JobRegistry
impl Sync for JobRegistry
impl Unpin for JobRegistry
impl !UnwindSafe for JobRegistry
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
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