From 3d76750ac8dacd95003ca89cf9542c3b2a014b8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 11 Aug 2023 01:38:32 +0200 Subject: [PATCH] fix: fix pool busyness semantic with task queueing enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 17 +++++++++++++---- src/pools/abstract-pool.ts | 25 ++++++++++++++++++------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 987e0e8a..8761941e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,16 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [2.6.22] - 2023-08-10 +### Fixed -## Changed +- Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker. -- Structure markdown documentation (PR #811). +### Added + +- HTTP client pool examples: fetch, node-fetch and axios with multiple task functions. +- HTTP server pool examples: express. + +## [2.6.22] - 2023-08-10 -## Fixed +### Fixed - Add missing `types` field to package.json `exports`. +### Changed + +- Structure markdown documentation (PR #811). + ## [2.6.21] - 2023-08-03 ### Changed diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index aec731a5..91cb5fac 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -615,17 +615,28 @@ export abstract class AbstractPool< protected abstract get busy (): boolean /** - * Whether worker nodes are executing at least one task. + * Whether worker nodes are executing concurrently their tasks quota or not. * * @returns Worker nodes busyness boolean status. */ protected internalBusy (): boolean { - return ( - this.workerNodes.findIndex( - workerNode => - workerNode.info.ready && workerNode.usage.tasks.executing === 0 - ) === -1 - ) + if (this.opts.enableTasksQueue === true) { + return ( + this.workerNodes.findIndex( + workerNode => + workerNode.info.ready && + workerNode.usage.tasks.executing < + (this.opts.tasksQueueOptions?.concurrency as number) + ) === -1 + ) + } else { + return ( + this.workerNodes.findIndex( + workerNode => + workerNode.info.ready && workerNode.usage.tasks.executing === 0 + ) === -1 + ) + } } /** @inheritDoc */ -- 2.34.1