X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool.ts;h=d80ddd7b2cb810c987c64dbcc40338d3b89735ab;hb=251d6ac2d29d7361d671a8df17af51b414ea3b83;hp=c7b878ae05814dec641298ca1630633ebc93b4b9;hpb=9768f49f952bcb39789e9b7b5679e1d635cb262d;p=poolifier.git diff --git a/src/pools/pool.ts b/src/pools/pool.ts index c7b878ae..d80ddd7b 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -79,6 +79,7 @@ export interface PoolInfo { readonly executingTasks: number readonly queuedTasks?: number readonly maxQueuedTasks?: number + readonly backPressure?: boolean readonly failedTasks: number readonly runTime?: { readonly minimum: number @@ -95,11 +96,17 @@ export interface PoolInfo { } /** - * Worker tasks queue options. + * Worker node tasks queue options. */ export interface TasksQueueOptions { /** - * Maximum number of tasks that can be executed concurrently on a worker. + * Maximum tasks queue size per worker node flagging it as back pressured. + * + * @defaultValue (pool maximum size)^2 + */ + readonly queueMaxSize?: number + /** + * Maximum number of tasks that can be executed concurrently on a worker node. * * @defaultValue 1 */ @@ -149,13 +156,13 @@ export interface PoolOptions { */ enableEvents?: boolean /** - * Pool worker tasks queue. + * Pool worker node tasks queue. * * @defaultValue false */ enableTasksQueue?: boolean /** - * Pool worker tasks queue options. + * Pool worker node tasks queue options. */ tasksQueueOptions?: TasksQueueOptions } @@ -201,7 +208,7 @@ export interface IPool< * - '`destroy`': Emitted when the pool is destroyed. * - `'error'`: Emitted when an uncaught error occurs. * - `'taskError'`: Emitted when an error occurs while executing a task. - * - `'backPressure'`: Emitted when a worker node has back pressure (i.e. its tasks queue is full). + * - `'backPressure'`: Emitted when all worker nodes have back pressure (i.e. their tasks queue is full: queue size \>= maximum queue size). */ readonly emitter?: PoolEmitter /** @@ -246,19 +253,19 @@ export interface IPool< workerChoiceStrategyOptions: WorkerChoiceStrategyOptions ) => void /** - * Enables/disables the worker tasks queue in this pool. + * Enables/disables the worker node tasks queue in this pool. * - * @param enable - Whether to enable or disable the worker tasks queue. - * @param tasksQueueOptions - The worker tasks queue options. + * @param enable - Whether to enable or disable the worker node tasks queue. + * @param tasksQueueOptions - The worker node tasks queue options. */ readonly enableTasksQueue: ( enable: boolean, tasksQueueOptions?: TasksQueueOptions ) => void /** - * Sets the worker tasks queue options in this pool. + * Sets the worker node tasks queue options in this pool. * - * @param tasksQueueOptions - The worker tasks queue options. + * @param tasksQueueOptions - The worker node tasks queue options. */ readonly setTasksQueueOptions: (tasksQueueOptions: TasksQueueOptions) => void }