refactor: more object destructuration cleanup in examples
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 16 Aug 2023 14:15:48 +0000 (16:15 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 16 Aug 2023 14:15:48 +0000 (16:15 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts
examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts
examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts

index 6e3a1dbfec643759ef30aecfd767e5f9d1c40e02..7426ed46f62300c701d20ddc9347bc5a58dd0b54 100644 (file)
@@ -20,11 +20,12 @@ const fastifyPoolifierPlugin: FastifyPluginCallback<FastifyPoolifierOptions> = (
     },
     ...options
   }
+  const { workerFile, minWorkers, maxWorkers, ...poolOptions } = options
   const pool = new DynamicThreadPool<ThreadWorkerData, ThreadWorkerResponse>(
-    options.minWorkers as number,
-    options.maxWorkers as number,
-    options.workerFile,
-    options
+    minWorkers as number,
+    maxWorkers as number,
+    workerFile,
+    poolOptions
   )
   if (!fastify.hasDecorator('pool')) {
     fastify.decorate('pool', pool)
index 15e5656b12abe44477a65dc7efd4a994b51663d7..85e22c12698cc8d3dbe2fb068c005e993ed8872f 100644 (file)
@@ -20,11 +20,12 @@ const fastifyPoolifierPlugin: FastifyPluginCallback<FastifyPoolifierOptions> = (
     },
     ...options
   }
+  const { workerFile, minWorkers, maxWorkers, ...poolOptions } = options
   const pool = new DynamicThreadPool<WorkerData, WorkerResponse>(
-    options.minWorkers as number,
-    options.maxWorkers as number,
-    options.workerFile,
-    options
+    minWorkers as number,
+    maxWorkers as number,
+    workerFile,
+    poolOptions
   )
   if (!fastify.hasDecorator('pool')) {
     fastify.decorate('pool', pool)
index 7785a0d6d2f2191f33a9e362853971bd0f86f1c3..143dc6db38deac7f40f27001b3aa51e7ba9c2e2b 100644 (file)
@@ -22,6 +22,7 @@ class WebSocketServerWorker extends ClusterWorker<WorkerData, WorkerResponse> {
     workerData?: WorkerData
   ): WorkerResponse => {
     const { port } = workerData as WorkerData
+
     WebSocketServerWorker.wss = new WebSocketServer({ port }, () => {
       console.info(
         `⚡️[ws server]: WebSocket server is started in cluster worker at ws://localhost:${port}/`