Skip to content

@saflib/jobs-db


index

Interfaces

InterfaceDescription
JobAuthorityAssertionEnqueue-hop identity assertion stored with the authority grant.
JobEntity-
JobRequestCapped request payload delivered to the target operation (≤ 16 KB serialized).
JobResultOutcome of a terminal or failed attempt; error_body only on failure (≤ 8 KB).

Type Aliases

Type AliasDescription
JobAuthorityRoot grant for the job chain, including the embedded enqueue assertion. Wire form omits assertion (returned separately as authority_assertion).
JobEntityTest-
JobStatus-
JobTerminalReason-

Variables

VariableDescription
cancelByIdJobCancel a pending/retrying job (terminal_reason: cancelled-by-admin). Running and terminal jobs return JobNotCancellableError.
cancelByOriginalRequestIdJobCancel every pending/retrying job in a chain (terminal_reason: cancelled-by-chain). Running and terminal jobs are left alone. Returns the cancelled rows (possibly empty).
claimNextJobAtomically claim the highest-priority eligible job.
countByOriginalRequestIdJobCount all jobs sharing an original_request_id (spawn-cap / lineage).
countByStatusJobCounts of jobs grouped by status (for the jobs_queue_depth gauge). Statuses with zero jobs are omitted.
createJob-
deleteExpiredTerminalJobRetention sweep: delete terminal jobs older than cutoff. Returns the number of rows deleted.
getByIdJob-
heartbeatJobRefresh heartbeat_at for a running job (stall detection).
jobsDb-
jobTable-
listJobList jobs with optional filters, newest first (created_at desc, then id).
listRunningJobsJobReturns all jobs currently in running status (for stall detection).
recordAttemptResultJobRecord a delivery attempt outcome. Only transitions from running.
recoverStalledJobRecover stalled deliveries: running jobs in ids become retrying if attempts remain, else dead with terminal_reason: exhausted. Returns the affected rows.
retryByIdJobRe-queue a dead/cancelled job as pending with a full attempt reset. Other statuses return JobNotRetryableError (409-style).

References

JobNotCancellableError

Re-exports JobNotCancellableError


JobNotFoundError

Re-exports JobNotFoundError


JobNotRetryableError

Re-exports JobNotRetryableError


JobNotRunningError

Re-exports JobNotRunningError


JobsDatabaseError

Re-exports JobsDatabaseError


JobSpawnCapExceededError

Re-exports JobSpawnCapExceededError