Skip to content

createInProcessWorker

createInProcessWorker<TJobTypeDefinitions, TStateAdapter, TProcessorsInput, TRequiredAttemptMiddleware>(options): Promise<InProcessWorker>

Defined in: packages/core/src/in-process-worker.ts:266

Create an in-process worker for processing jobs.

Per-attempt configuration (attemptMiddleware, backoffConfig, attemptConfig) lives on the processor registry (see createProcessors). The worker dispatches to whichever processor matches the job’s typeName and runs that slice’s middleware chain. Worker-level defaults provide fallbacks for processors that don’t set backoffConfig / attemptConfig themselves; precedence is processor > worker defaults > built-in defaults.

TJobTypeDefinitions extends BaseJobTypeDefinitions

TStateAdapter extends StateAdapter<any, any>

TProcessorsInput extends Processors | readonly Processors[] = Processors

TRequiredAttemptMiddleware extends readonly AnyAttemptMiddleware[] = readonly []

Worker configuration.

Client<TJobTypeDefinitions, TStateAdapter>

The Queuert client to process jobs for.

number

Maximum number of jobs to process in parallel. Defaults to 1.

InProcessWorkerDefaults

Fallback backoffConfig / attemptConfig for processors that don’t set their own.

number

How often to poll for new jobs when no notify adapter wakes the worker. Defaults to 60s.

[ExtraProcessorTypeNames<WorkerProcessorDefs<TProcessorsInput>, TJobTypeDefinitions>] extends [never] ? ValidateRequiredMiddleware<TProcessorsInput, TRequiredAttemptMiddleware> : `Error: processors contain job types unknown to the client: ${ExtraProcessorTypeNames<WorkerProcessorDefs<TProcessorsInput>, TJobTypeDefinitions> & string}`

A single Processors from createProcessors, or an array of slices to merge.

BackoffConfig

Backoff configuration for the worker loop itself (not job retries).

TRequiredAttemptMiddleware & readonly AttemptMiddleware<TStateAdapter, any, any, any, any>[]

Middleware instances that every dispatched processor’s slice must include as an in-order subsequence. Enforced both at compile time (against the slice middleware tuple inferred by createProcessors) and at runtime by reference-identity (===). The worker does not execute this middleware itself — slices run their own chains.

Same adapter guard as createProcessors’s attemptMiddleware.

string

Optional human-readable label included in the worker id (which is always suffixed with a random UUID to guarantee uniqueness across replicas). Must match /^[A-Za-z0-9._-]+$/ when provided.

Promise<InProcessWorker>