Interface PoolOptions<Worker>

Options for a poolifier pool.

interface PoolOptions<Worker> {
    enableEvents?: boolean;
    enableTasksQueue?: boolean;
    env?: Record<string, unknown>;
    errorHandler?: ErrorHandler<Worker>;
    exitHandler?: ExitHandler<Worker>;
    messageHandler?: MessageHandler<Worker>;
    onlineHandler?: OnlineHandler<Worker>;
    restartWorkerOnError?: boolean;
    settings?: ClusterSettings;
    startWorkers?: boolean;
    tasksQueueOptions?: TasksQueueOptions;
    workerChoiceStrategy?:
        | "FAIR_SHARE"
        | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
        | "LEAST_BUSY"
        | "LEAST_ELU"
        | "LEAST_USED"
        | "ROUND_ROBIN"
        | "WEIGHTED_ROUND_ROBIN";
    workerChoiceStrategyOptions?: WorkerChoiceStrategyOptions;
    workerOptions?: WorkerOptions;
}

Type Parameters

  • Worker extends IWorker

    Type of worker.

Properties

enableEvents?: boolean

Pool events integrated with async resource emission.

true
enableTasksQueue?: boolean

Pool worker node tasks queue.

false
env?: Record<string, unknown>

Key/value pairs to add to worker process environment.

errorHandler?: ErrorHandler<Worker>

A function that will listen for error event on each worker.

() => {}

exitHandler?: ExitHandler<Worker>

A function that will listen for exit event on each worker.

() => {}

messageHandler?: MessageHandler<Worker>

A function that will listen for message event on each worker.

() => {}

onlineHandler?: OnlineHandler<Worker>

A function that will listen for online event on each worker.

() => {}

restartWorkerOnError?: boolean

Restart worker on error.

settings?: ClusterSettings

Cluster settings.

startWorkers?: boolean

Whether to start the minimum number of workers at pool initialization.

true
tasksQueueOptions?: TasksQueueOptions

Pool worker node tasks queue options.

workerChoiceStrategy?:
    | "FAIR_SHARE"
    | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
    | "LEAST_BUSY"
    | "LEAST_ELU"
    | "LEAST_USED"
    | "ROUND_ROBIN"
    | "WEIGHTED_ROUND_ROBIN"

The default worker choice strategy to use in this pool.

WorkerChoiceStrategies.ROUND_ROBIN
workerChoiceStrategyOptions?: WorkerChoiceStrategyOptions

The worker choice strategy options.

workerOptions?: WorkerOptions

Worker options.