refactor: cleanup type import
[poolifier.git] / examples / typescript / websocket-server-pool / ws-hybrid / src / main.ts
index d9e827cbfa262f83613cb01c8201b70efdfec4a7..3adac7e819b3c6a35fd5fbd6f40196ea1df2846b 100644 (file)
@@ -1,7 +1,7 @@
 import { dirname, extname, join } from 'node:path'
 import { fileURLToPath } from 'node:url'
 import { FixedClusterPool, availableParallelism } from 'poolifier'
-import { type ClusterWorkerData, type ClusterWorkerResponse } from './types.js'
+import type { ClusterWorkerData, ClusterWorkerResponse } from './types.js'
 
 const webSocketServerWorkerFile = join(
   dirname(fileURLToPath(import.meta.url)),
@@ -21,7 +21,10 @@ const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
       pool
         .execute({
           port: 8080,
-          maxWorkers: Math.round(availableParallelism() / 2),
+          maxWorkers:
+            Math.round(availableParallelism() / 4) < 1
+              ? 1
+              : Math.round(availableParallelism() / 4),
           workerFile: requestHandlerWorkerFile,
           enableTasksQueue: true,
           tasksQueueOptions: {