Struct sqlxmq::JobRegistry
source · 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 !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