Skip to main content

Interface: WorkerDefinition

Defined in: src/interfaces.ts:180

Configuration for a single worker instance. Allows defining multiple workers with different task queues.

Example​

const workerDef: WorkerDefinition = {
taskQueue: 'payments-queue',
workflowsPath: './dist/workflows/payments',
activityClasses: [PaymentActivity],
autoStart: true,
autoRestart: true,
maxRestarts: 5,
workerOptions: {
maxConcurrentActivityTaskExecutions: 100
}
};

Properties​

activityClasses?​

optional activityClasses?: Type<object>[]

Defined in: src/interfaces.ts:200


autoBundle?​

optional autoBundle?: boolean | AutoBundleOptions

Defined in: src/interfaces.ts:193

Bundle workflowsPath at startup instead of leaving it to the SDK, and cache the result by content hash so an unchanged source skips bundling on every restart. true uses defaults. Requires workflowsPath; cannot be combined with workflowBundle.


autoRestart?​

optional autoRestart?: boolean

Defined in: src/interfaces.ts:203

Enable auto-restart on worker failure (default: inherits from global autoRestart)


autoStart?​

optional autoStart?: boolean

Defined in: src/interfaces.ts:201


maxRestarts?​

optional maxRestarts?: number

Defined in: src/interfaces.ts:205

Maximum restart attempts before giving up (default: 3)


taskQueue​

taskQueue: string

Defined in: src/interfaces.ts:181


workerOptions?​

optional workerOptions?: WorkerCreateOptions

Defined in: src/interfaces.ts:206


workflowBundle?​

optional workflowBundle?: WorkflowBundleOption | Record<string, unknown>

Defined in: src/interfaces.ts:199

Workflow bundle. Prefer Temporal SDK's WorkflowBundleOption ({ code } or { codePath }). Loose shape accepted for backward compatibility.


workflowsPath?​

optional workflowsPath?: string

Defined in: src/interfaces.ts:187

Where the workflows live. Relative paths resolve against process.cwd(), and .ts / .js are swapped when only the other exists, so one path works in dev and from dist/. A wrong path fails at startup with a clear message.