pub struct JobRegistry { /* private fields */ }Expand description
Dispatches SQLite-queued jobs to discovered JobDef handlers.
Implementations§
Source§impl JobRegistry
impl JobRegistry
Sourcepub fn new(jobs: Vec<JobDef>) -> Self
pub fn new(jobs: Vec<JobDef>) -> Self
Build a registry from discovered jobs, including the built-in slabs.deliver_webhook handler.
Sourcepub async fn run_now(
&self,
ctx: &AppCtx,
job_name: &str,
payload: Value,
) -> SlabResult<()>
pub async fn run_now( &self, ctx: &AppCtx, job_name: &str, payload: Value, ) -> SlabResult<()>
Execute a registered job directly by name (ideal for testing scheduled/maintenance jobs).
Sourcepub async fn dispatch(&self, ctx: &AppCtx, job: &JobRecord) -> SlabResult<()>
pub async fn dispatch(&self, ctx: &AppCtx, job: &JobRecord) -> SlabResult<()>
Dispatch a claimed JobRecord to its registered handler.
If the stored JSON payload cannot be parsed (a poison pill), immediately dead-letters the
job via Jobs::mark_dead, records a job_dead incident (firing the incident webhook on
Opened or Reopened), and returns an error so it cannot stall the queue.
Sourcepub async fn run_next(&self, ctx: &AppCtx) -> SlabResult<bool>
pub async fn run_next(&self, ctx: &AppCtx) -> SlabResult<bool>
Claim and execute the next ready job from the queue, returning Ok(true) if a job was processed.
Sourcepub async fn drain_ready(&self, ctx: &AppCtx) -> SlabResult<usize>
pub async fn drain_ready(&self, ctx: &AppCtx) -> SlabResult<usize>
Repeatedly run ready jobs until the queue is empty, returning the number of jobs processed.
Sourcepub fn spawn_workers(&self, ctx: &AppCtx)
pub fn spawn_workers(&self, ctx: &AppCtx)
Spawn background job worker tasks without an external shutdown signal.
Sourcepub fn spawn_workers_with_shutdown(
&self,
ctx: &AppCtx,
shutdown: &Receiver<bool>,
) -> Vec<JoinHandle<()>>
pub fn spawn_workers_with_shutdown( &self, ctx: &AppCtx, shutdown: &Receiver<bool>, ) -> Vec<JoinHandle<()>>
Spawn background job worker tasks that stop cleanly when shutdown is signaled.
Delegates execution to Jobs::spawn_workers_with_telemetry for lease reclamation,
timeouts, panic isolation, dead-letter incident capture, and slow-job tracking,
returning the spawned JoinHandles for graceful drain.
Sourcepub fn spawn_schedules(&self, ctx: &AppCtx, schedules: Vec<ScheduleDef>)
pub fn spawn_schedules(&self, ctx: &AppCtx, schedules: Vec<ScheduleDef>)
Spawn recurring schedule tasks without an external shutdown signal.
Sourcepub fn spawn_schedules_with_shutdown(
&self,
ctx: &AppCtx,
schedules: Vec<ScheduleDef>,
shutdown: &Receiver<bool>,
) -> Vec<JoinHandle<()>>
pub fn spawn_schedules_with_shutdown( &self, ctx: &AppCtx, schedules: Vec<ScheduleDef>, shutdown: &Receiver<bool>, ) -> Vec<JoinHandle<()>>
Spawn recurring schedule tasks that stop cleanly when shutdown is signaled, returning
their JoinHandles.
Trait Implementations§
Source§impl Clone for JobRegistry
impl Clone for JobRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for JobRegistry
impl !UnwindSafe for JobRegistry
impl Forget for JobRegistry
impl Freeze for JobRegistry
impl Move for JobRegistry
impl Send for JobRegistry
impl Sync for JobRegistry
impl Unpin for JobRegistry
impl UnsafeUnpin for JobRegistrywhere
*const ArcInner<HashMap<String, JobDef>> is !null: UnsafeUnpin,
PhantomData<ArcInner<HashMap<String, JobDef>>>: 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
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,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read more