Skip to main content

JobCatalog

Struct JobCatalog 

Source
pub struct JobCatalog { /* private fields */ }
Expand description

Single-source registry of job handlers, definition defaults, and enqueue helpers.

Implementations§

Source§

impl JobCatalog

Source

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.

Source

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.

Source

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

Source

pub fn new() -> Self

Creates an empty catalog with default definition values.

Source

pub fn defaults(self, defaults: JobCatalogDefaults) -> Self

Replaces the definition defaults used by subsequent sync operations.

Source

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.

Source

pub fn job<H>(self, job_type: &'static str, handler: H) -> Self
where H: JobHandler + 'static,

Registers a handler, panicking when validation fails.

Source

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.

Source

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.

Source

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.

Source

pub fn contains(&self, job_type: JobType<'_>) -> bool

Returns whether the catalog has a registered job type.

Source

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.

Source

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

Source

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.

Source

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

Source

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

Source§

fn clone(&self) -> JobCatalog

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JobCatalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for JobCatalog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more