pub struct JobCatalog { /* private fields */ }Expand description
Single-source registry of job handlers, definition defaults, and enqueue helpers.
Implementations§
Source§impl JobCatalog
impl JobCatalog
Sourcepub fn job_enqueue<'a>(
&self,
input: &CatalogJobEnqueueInput<'a>,
) -> Result<JobEnqueue<'a>, CatalogError>
pub fn job_enqueue<'a>( &self, input: &CatalogJobEnqueueInput<'a>, ) -> Result<JobEnqueue<'a>, CatalogError>
Builds a JobEnqueue after validating the job type is registered and enabled.
This checks catalog configuration only. Operator-disabled database rows
are still enforced by runledger-postgres when the job is enqueued.
Catalog defaults’ enabled flag applies to every catalog entry; per-job
enabled overrides are not modeled yet.
Sourcepub fn job_schedule<'a>(
&self,
input: &CatalogJobScheduleInput<'a>,
) -> Result<JobScheduleUpsert<'a>, CatalogError>
pub fn job_schedule<'a>( &self, input: &CatalogJobScheduleInput<'a>, ) -> Result<JobScheduleUpsert<'a>, CatalogError>
Builds a JobScheduleUpsert after validating the job type is registered and enabled.
This checks catalog configuration only. Operator-disabled database rows
are still enforced by runledger-postgres when schedule-created jobs are
materialized.
Catalog defaults’ enabled flag applies to every catalog entry; per-job
enabled overrides are not modeled yet.
Sourcepub fn workflow_step<'a>(
&self,
step_key: &'a str,
job_type_name: &str,
payload: &'a Value,
) -> Result<WorkflowStepEnqueueBuilder<'a>, CatalogError>
pub fn workflow_step<'a>( &self, step_key: &'a str, job_type_name: &str, payload: &'a Value, ) -> Result<WorkflowStepEnqueueBuilder<'a>, CatalogError>
Builds a workflow step after validating the job type is registered and enabled.
Source§impl JobCatalog
impl JobCatalog
Sourcepub fn defaults(self, defaults: JobCatalogDefaults) -> Self
pub fn defaults(self, defaults: JobCatalogDefaults) -> Self
Replaces the definition defaults used by subsequent sync operations.
Sourcepub fn try_job<H>(
self,
job_type: &'static str,
handler: H,
) -> Result<Self, CatalogError>where
H: JobHandler + 'static,
pub fn try_job<H>(
self,
job_type: &'static str,
handler: H,
) -> Result<Self, CatalogError>where
H: JobHandler + 'static,
Registers a handler after validating declared and handler job types match.
§Errors
Returns CatalogError when job types are blank, mismatched, or duplicated.
Sourcepub fn job<H>(self, job_type: &'static str, handler: H) -> Selfwhere
H: JobHandler + 'static,
pub fn job<H>(self, job_type: &'static str, handler: H) -> Selfwhere
H: JobHandler + 'static,
Registers a handler, panicking when validation fails.
Sourcepub fn try_retry_delay_override(
self,
job_type: &str,
failure_code: &'static str,
retry_delay_ms: i32,
) -> Result<Self, CatalogError>
pub fn try_retry_delay_override( self, job_type: &str, failure_code: &'static str, retry_delay_ms: i32, ) -> Result<Self, CatalogError>
Registers a retry-delay override for a catalog job type.
§Errors
Returns CatalogError when the job type is unknown or override values are invalid.
Sourcepub fn retry_delay_override(
self,
job_type: &str,
failure_code: &'static str,
retry_delay_ms: i32,
) -> Self
pub fn retry_delay_override( self, job_type: &str, failure_code: &'static str, retry_delay_ms: i32, ) -> Self
Registers a retry-delay override, panicking when validation fails.
Sourcepub fn to_registry(&self) -> JobRegistry
pub fn to_registry(&self) -> JobRegistry
Converts the catalog into a runtime JobRegistry.
Disabled catalog defaults still register handlers so workers can process already-queued work and dead-letter hooks.
Sourcepub fn contains(&self, job_type: JobType<'_>) -> bool
pub fn contains(&self, job_type: JobType<'_>) -> bool
Returns whether the catalog has a registered job type.
Sourcepub fn require_job_type(
&self,
job_type: &str,
) -> Result<JobType<'static>, CatalogError>
pub fn require_job_type( &self, job_type: &str, ) -> Result<JobType<'static>, CatalogError>
Returns a catalog job type when it is registered.
§Errors
Returns CatalogError::UnknownJobType when the name is not in the catalog.
Sourcepub fn require_catalog_enabled_job_type(
&self,
job_type: &str,
) -> Result<JobType<'static>, CatalogError>
pub fn require_catalog_enabled_job_type( &self, job_type: &str, ) -> Result<JobType<'static>, CatalogError>
Returns a catalog job type when it is registered and catalog-enabled.
This checks catalog configuration only. It does not read job_definitions;
operator-disabled database rows are enforced later by persistence APIs.
Catalog defaults’ enabled flag applies to every catalog entry; per-job
enabled overrides are not modeled yet.
§Errors
Returns CatalogError::UnknownJobType or CatalogError::DisabledJobType.
Source§impl JobCatalog
impl JobCatalog
Sourcepub async fn sync_definitions(
&self,
pool: &DbPool,
) -> Result<JobCatalogSyncReport, CatalogError>
pub async fn sync_definitions( &self, pool: &DbPool, ) -> Result<JobCatalogSyncReport, CatalogError>
Upserts every catalog job into job_definitions.
The catalog owns the synced definition fields: repeated syncs overwrite
version, max_attempts, default_timeout_seconds, and
default_priority for registered jobs. Enabled catalogs preserve an
existing disabled row so operator pauses survive worker restarts; disabled
catalogs explicitly write is_enabled = false.
Safe to call repeatedly. Does not delete or disable definitions absent from the catalog.
Use Self::sync_definitions_exact with an explicit scope when removed
catalog entries should be disabled.
Disabled catalog sync briefly locks job_schedules and job_definitions
so active schedule checks and definition disables are evaluated against a
stable write boundary.
§Errors
Returns CatalogError when defaults are invalid or persistence fails.
Sourcepub async fn sync_definitions_exact(
&self,
pool: &DbPool,
scope: &JobCatalogSyncScope,
) -> Result<JobCatalogExactSyncReport, CatalogError>
pub async fn sync_definitions_exact( &self, pool: &DbPool, scope: &JobCatalogSyncScope, ) -> Result<JobCatalogExactSyncReport, CatalogError>
Upserts catalog jobs, then disables enabled job_definitions rows in
scope whose job type is absent from the catalog.
This is the stricter startup mode for applications that want the catalog
to be the active job-definition source of truth. It never deletes rows,
never operates outside the supplied owned job-type set, and rejects active
schedules that still reference a job type it would disable. Unlike
Self::sync_definitions, exact sync restores catalog entries’
is_enabled value from catalog defaults.
Exact sync briefly locks job_schedules and job_definitions before it
checks active schedules or disables definitions, so it is heavier than the
additive sync path.
§Errors
Returns CatalogError when the scope is invalid, the catalog is empty,
a catalog job is outside the scope, active schedules still reference
absent scoped jobs, or persistence fails.
Source§impl JobCatalog
impl JobCatalog
Sourcepub fn workflow_dag<'a>(
&self,
workflow_type: &'a str,
metadata: &'a Value,
) -> CatalogWorkflowDagBuilder<'a, '_>
pub fn workflow_dag<'a>( &self, workflow_type: &'a str, metadata: &'a Value, ) -> CatalogWorkflowDagBuilder<'a, '_>
Starts a workflow DAG builder that validates step job types against the catalog.
Trait Implementations§
Source§impl Clone for JobCatalog
impl Clone for JobCatalog
Source§fn clone(&self) -> JobCatalog
fn clone(&self) -> JobCatalog
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JobCatalog
impl Debug for JobCatalog
Auto Trait Implementations§
impl Freeze for JobCatalog
impl !RefUnwindSafe for JobCatalog
impl Send for JobCatalog
impl Sync for JobCatalog
impl Unpin for JobCatalog
impl UnsafeUnpin for JobCatalog
impl !UnwindSafe for JobCatalog
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more