X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool.ts;h=6058a3dea2aa9c0d55ce5f65bba695406a8875c9;hb=af7fe15acbe47c6b2236426034dd5cb08c271bbc;hp=581adc952c1e5a1a1b7e1f11c033283dc5df5fa5;hpb=7379799cccb092ed5e83b388977a25a8a23ac37b;p=poolifier.git diff --git a/src/pools/pool.ts b/src/pools/pool.ts index 581adc95..6058a3de 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -1,5 +1,6 @@ -import type { TransferListItem } from 'node:worker_threads' +import type { TransferListItem, WorkerOptions } from 'node:worker_threads' import type { EventEmitterAsyncResource } from 'node:events' +import type { ClusterSettings } from 'node:cluster' import type { TaskFunction } from '../worker/task-functions' import type { ErrorHandler, @@ -110,7 +111,7 @@ export interface TasksQueueOptions { */ readonly concurrency?: number /** - * Whether to enable task stealing on empty queue. + * Whether to enable task stealing on idle. * * @defaultValue true */ @@ -121,6 +122,12 @@ export interface TasksQueueOptions { * @defaultValue true */ readonly tasksStealingOnBackPressure?: boolean + /** + * Queued tasks finished timeout in milliseconds at worker node termination. + * + * @defaultValue 2000 + */ + readonly tasksFinishedTimeout?: number } /** @@ -189,6 +196,24 @@ export interface PoolOptions { * Pool worker node tasks queue options. */ tasksQueueOptions?: TasksQueueOptions + /** + * Worker options. + * + * @see https://nodejs.org/api/worker_threads.html#new-workerfilename-options + */ + workerOptions?: WorkerOptions + /** + * Key/value pairs to add to worker process environment. + * + * @see https://nodejs.org/api/cluster.html#cluster_cluster_fork_env + */ + env?: Record + /** + * Cluster settings. + * + * @see https://nodejs.org/api/cluster.html#cluster_cluster_settings + */ + settings?: ClusterSettings } /**