API reference
job(options) creates a Layeron Job module for durable background task execution, delayed runs, retries, and replay.
Import
Section titled “Import”import { job } from "@layeron/modules"Create a Layeron Job module for durable task execution.
job(options: JobModuleOptions): JobModuleJobRetryOptions
Section titled “JobRetryOptions”Retry policy for a Job module or task.
| Field | Type | Description |
|---|---|---|
attempts | int32 | undefined | Maximum attempts for a run, including the first attempt. |
backoff | JobBackoffMode | undefined | Backoff algorithm between failed attempts. |
initialDelaySeconds | int32 | undefined | First retry delay in seconds. |
maxDelaySeconds | int32 | undefined | Maximum retry delay in seconds. |
JobQueueConsumerOptions
Section titled “JobQueueConsumerOptions”Queue consumer controls for Job delivery.
| Field | Type | Description |
|---|---|---|
batchSize | int32 | undefined | Maximum messages delivered in one Queue batch. |
concurrency | int32 | undefined | Maximum concurrent task executions for this Job consumer. |
visibilityTimeoutSeconds | int32 | undefined | Seconds before a leased Queue message becomes available again. |
JobQueueOptions
Section titled “JobQueueOptions”Queue configuration for a Job module.
| Field | Type | Description |
|---|---|---|
name | string | undefined | Stable delivery queue name. Defaults to the Job name with a -jobs suffix. |
consumer | JobQueueConsumerOptions | undefined | Consumer controls for the delivery queue. |
JobModuleOptions
Section titled “JobModuleOptions”Options accepted by job(options).
| Field | Type | Description |
|---|---|---|
name | string | Stable Job instance name. |
namespace | string | undefined | Platform namespace for the instance. Defaults to default. |
queue | JobQueueOptions | undefined | Queue configuration for task delivery. |
retry | JobRetryOptions | undefined | Default retry policy inherited by tasks. |
observability | Layeron.Observability.ObservabilityConfig | undefined | Observability settings for job enqueue, execution, retry, and replay records. |
JobTaskOptions
Section titled “JobTaskOptions”Options accepted when registering a Job task.
| Field | Type | Description |
|---|---|---|
payloadSchemaId | string | undefined | Identifier for the payload schema used by this task. |
retry | JobRetryOptions | undefined | Retry policy for this task. Defaults to the Job module retry policy. |
timeoutSeconds | int32 | undefined | Maximum task execution time in seconds. |
JobEnqueueOptions
Section titled “JobEnqueueOptions”Options accepted when enqueueing a Job run.
| Field | Type | Description |
|---|---|---|
idempotencyKey | string | undefined | Application idempotency key used to reuse an existing run for duplicate enqueue calls. |
delaySeconds | int32 | undefined | Delay in seconds before the run becomes eligible for execution. |
runAt | string | undefined | Date or RFC3339 timestamp when the run becomes eligible for execution. |
traceId | string | undefined | Trace id attached to the run and its attempts. |
JobModule
Section titled “JobModule”Layeron Job module returned by job(options).
| Field | Type | Description |
|---|---|---|
name | ”job” | Module name. |
config | JobModuleOptions | Normalized Job module configuration. |
observability | Layeron.Observability.ObservabilityConfig | undefined | Effective observability policy recorded on the module declaration. |
JobBackoffMode
Section titled “JobBackoffMode”Retry backoff mode for Job retry attempts.
| Value | Description |
|---|---|
fixed | Use the same retry delay for each failed attempt. |
exponential | Increase retry delay after each failed attempt. |
Operations
Section titled “Operations”TypeScript result contracts
Section titled “TypeScript result contracts”These TypeScript result contracts are part of the public module API.
| Result |
|---|
JobEnqueueResult |