X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool.ts;h=d7b6eeabeb074c31103854ec2f9789d137ff8409;hb=98f60ddd83d32e108adcfddebeb902f0d5a197eb;hp=cda63d881f0bab742cf0412cfa266714fdefeb27;hpb=e372f3935374fbbea3a5d3acc72813b36ced86ff;p=poolifier.git diff --git a/src/pools/pool.ts b/src/pools/pool.ts index cda63d88..d7b6eeab 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,15 +16,14 @@ import type { OnlineHandler, WorkerType } from './worker.js' -import type { - WorkerChoiceStrategy, - WorkerChoiceStrategyOptions -} from './selection-strategies/selection-strategies-types.js' /** * Enumeration of pool types. */ -export const PoolTypes = Object.freeze({ +export const PoolTypes: Readonly<{ + fixed: 'fixed' + dynamic: 'dynamic' +}> = Object.freeze({ /** * Fixed pool type. */ @@ -38,7 +42,16 @@ export type PoolType = keyof typeof PoolTypes /** * Enumeration of pool events. */ -export const PoolEvents = Object.freeze({ +export const PoolEvents: Readonly<{ + ready: 'ready' + busy: 'busy' + full: 'full' + empty: 'empty' + destroy: 'destroy' + error: 'error' + taskError: 'taskError' + backPressure: 'backPressure' +}> = Object.freeze({ ready: 'ready', busy: 'busy', full: 'full', @@ -64,6 +77,7 @@ export interface PoolInfo { readonly started: boolean readonly ready: boolean readonly strategy: WorkerChoiceStrategy + readonly strategyRetries: number readonly minSize: number readonly maxSize: number /** Pool utilization. */ @@ -242,7 +256,7 @@ 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: