Skip to content

CustomManagerAdapter

Signature

export interface CustomManagerAdapter

Properties

0

No properties.

Methods

3

Methods

postMessage(workerId: number, body: unknown, generation?: number): Awaitable<unknown>;

Delivers a message to a worker. `generation` identifies the worker instance: `0` for workers spawned normally, and the `workerData.generation` of a hot reload replacement. While a worker is hot reloaded, two instances share its id, so an adapter that supports hot reload must route by both values.

terminate?(workerId: number, generation: number): Awaitable<unknown>;

Stops one worker instance. Required for `WorkerManager.hotReload` in custom mode, which uses it to remove a failed replacement or a drained worker. Messages from a non-zero generation must be passed to `manager.handleWorkerMessage(message, generation)`, and a crashed instance reported with `manager.handleWorkerExit(workerId, generation, error)`.