fix: fix pool busyness semantic with task queueing enabled
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 10 Aug 2023 23:38:32 +0000 (01:38 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 10 Aug 2023 23:38:32 +0000 (01:38 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
CHANGELOG.md
src/pools/abstract-pool.ts

index 987e0e8a37618eaaea4e08c82ace56577dc92b5a..8761941ed05c7daf1833b0024ccae658eb9a27b9 100644 (file)
@@ -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
index aec731a5c189903b46230ceceeb831768fa62425..91cb5facd01f736d43703d4d0530ec7c01a3bf41 100644 (file)
@@ -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 */