fix: fix pool sizing in examples
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 14 Aug 2023 00:09:47 +0000 (02:09 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 14 Aug 2023 00:09:47 +0000 (02:09 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
examples/typescript/http-server-pool/fastify-hybrid/src/main.ts
examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts

index 5fc7542b7779df64a0f0aeab87ecc1ac13220246..d840dfb9529d0c01e659e7e8b79080cdb3c5938b 100644 (file)
@@ -22,7 +22,10 @@ const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
         .execute({
           port: 8080,
           workerFile: requestHandlerWorkerFile,
-          maxWorkers: Math.round(availableParallelism() / 4),
+          maxWorkers:
+            Math.round(availableParallelism() / 4) < 1
+              ? 1
+              : Math.round(availableParallelism() / 4),
           enableTasksQueue: true,
           tasksQueueOptions: {
             concurrency: 8
index b9e48bdd2ee194abf47d6d1b69eddd3dc134100d..5cfbbf43e36e3f6fe0595bd9c1256cc8bcbf6f3e 100644 (file)
@@ -21,7 +21,10 @@ const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
       pool
         .execute({
           port: 8080,
-          maxWorkers: Math.round(availableParallelism() / 4),
+          maxWorkers:
+            Math.round(availableParallelism() / 4) < 1
+              ? 1
+              : Math.round(availableParallelism() / 4),
           workerFile: requestHandlerWorkerFile,
           enableTasksQueue: true,
           tasksQueueOptions: {