Skip to content

API reference

job(options) creates a Layeron Job module for durable background task execution, delayed runs, retries, and replay.

Terminal window
import { job } from "@layeron/modules"

Create a Layeron Job module for durable task execution.

Terminal window
job(options: JobModuleOptions): JobModule

Retry policy for a Job module or task.

FieldTypeDescription
attemptsint32 | undefinedMaximum attempts for a run, including the first attempt.
backoffJobBackoffMode | undefinedBackoff algorithm between failed attempts.
initialDelaySecondsint32 | undefinedFirst retry delay in seconds.
maxDelaySecondsint32 | undefinedMaximum retry delay in seconds.

Queue consumer controls for Job delivery.

FieldTypeDescription
batchSizeint32 | undefinedMaximum messages delivered in one Queue batch.
concurrencyint32 | undefinedMaximum concurrent task executions for this Job consumer.
visibilityTimeoutSecondsint32 | undefinedSeconds before a leased Queue message becomes available again.

Queue configuration for a Job module.

FieldTypeDescription
namestring | undefinedStable delivery queue name. Defaults to the Job name with a -jobs suffix.
consumerJobQueueConsumerOptions | undefinedConsumer controls for the delivery queue.

Options accepted by job(options).

FieldTypeDescription
namestringStable Job instance name.
namespacestring | undefinedPlatform namespace for the instance. Defaults to default.
queueJobQueueOptions | undefinedQueue configuration for task delivery.
retryJobRetryOptions | undefinedDefault retry policy inherited by tasks.
observabilityLayeron.Observability.ObservabilityConfig | undefinedObservability settings for job enqueue, execution, retry, and replay records.

Options accepted when registering a Job task.

FieldTypeDescription
payloadSchemaIdstring | undefinedIdentifier for the payload schema used by this task.
retryJobRetryOptions | undefinedRetry policy for this task. Defaults to the Job module retry policy.
timeoutSecondsint32 | undefinedMaximum task execution time in seconds.

Options accepted when enqueueing a Job run.

FieldTypeDescription
idempotencyKeystring | undefinedApplication idempotency key used to reuse an existing run for duplicate enqueue calls.
delaySecondsint32 | undefinedDelay in seconds before the run becomes eligible for execution.
runAtstring | undefinedDate or RFC3339 timestamp when the run becomes eligible for execution.
traceIdstring | undefinedTrace id attached to the run and its attempts.

Layeron Job module returned by job(options).

FieldTypeDescription
name”job”Module name.
configJobModuleOptionsNormalized Job module configuration.
observabilityLayeron.Observability.ObservabilityConfig | undefinedEffective observability policy recorded on the module declaration.

Retry backoff mode for Job retry attempts.

ValueDescription
fixedUse the same retry delay for each failed attempt.
exponentialIncrease retry delay after each failed attempt.

These TypeScript result contracts are part of the public module API.

Result
JobEnqueueResult