X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool.ts;h=1fa5b0f5e333a18c706d24705cc297b27d47d2ba;hb=45bfccce0607e9f9f089374dad9f5b16960e272e;hp=3aa9feb70b04d8ea3b321777dd053d9823d994b0;hpb=04d875a3942abe97ce35c177c6e6f41619be974b;p=poolifier.git diff --git a/src/pools/pool.ts b/src/pools/pool.ts index 3aa9feb7..1fa5b0f5 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -1,7 +1,12 @@ -import type { TransferListItem, WorkerOptions } from 'node:worker_threads' -import type { EventEmitterAsyncResource } from 'node:events' import type { ClusterSettings } from 'node:cluster' +import type { EventEmitterAsyncResource } from 'node:events' +import type { TransferListItem, WorkerOptions } from 'node:worker_threads' + import type { TaskFunction } from '../worker/task-functions.js' +import type { + WorkerChoiceStrategy, + WorkerChoiceStrategyOptions +} from './selection-strategies/selection-strategies-types.js' import type { ErrorHandler, ExitHandler, @@ -11,10 +16,6 @@ import type { OnlineHandler, WorkerType } from './worker.js' -import type { - WorkerChoiceStrategy, - WorkerChoiceStrategyOptions -} from './selection-strategies/selection-strategies-types.js' /** * Enumeration of pool types. @@ -42,6 +43,7 @@ export const PoolEvents = Object.freeze({ ready: 'ready', busy: 'busy', full: 'full', + empty: 'empty', destroy: 'destroy', error: 'error', taskError: 'taskError', @@ -63,6 +65,7 @@ export interface PoolInfo { readonly started: boolean readonly ready: boolean readonly strategy: WorkerChoiceStrategy + readonly strategyRetries: number readonly minSize: number readonly maxSize: number /** Pool utilization. */ @@ -241,14 +244,15 @@ export interface IPool< */ readonly workerNodes: Array> /** - * Event emitter integrated with async resource on which events can be listened to. + * Pool event emitter integrated with async resource. * The async tracking tooling identifier is `poolifier:--pool`. * * Events that can currently be listened to: * - * - `'ready'`: Emitted when the number of workers created in the pool has reached the minimum size expected and are ready. + * - `'ready'`: Emitted when the number of workers created in the pool has reached the minimum size expected and are ready. If the pool is dynamic with a minimum number of workers is set to zero, this event is emitted when at least one dynamic worker is ready. * - `'busy'`: Emitted when the number of workers created in the pool has reached the maximum size expected and are executing concurrently their tasks quota. * - `'full'`: Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected. + * - `'empty'`: Emitted when the pool is dynamic with a minimum number of workers set to zero and the number of workers has reached the minimum size expected. * - `'destroy'`: Emitted when the pool is destroyed. * - `'error'`: Emitted when an uncaught error occurs. * - `'taskError'`: Emitted when an error occurs while executing a task.