From 30369cc0f200d553cfc72fce6e8685c66fa1e344 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 16 Aug 2023 16:15:48 +0200 Subject: [PATCH] refactor: more object destructuration cleanup in examples MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../fastify-hybrid/src/fastify-poolifier.ts | 9 +++++---- .../fastify-worker_threads/src/fastify-poolifier.ts | 9 +++++---- .../websocket-server-pool/ws-cluster/src/worker.ts | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts index 6e3a1dbf..7426ed46 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts @@ -20,11 +20,12 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( }, ...options } + const { workerFile, minWorkers, maxWorkers, ...poolOptions } = options const pool = new DynamicThreadPool( - 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) diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts index 15e5656b..85e22c12 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts @@ -20,11 +20,12 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( }, ...options } + const { workerFile, minWorkers, maxWorkers, ...poolOptions } = options const pool = new DynamicThreadPool( - 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) diff --git a/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts b/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts index 7785a0d6..143dc6db 100644 --- a/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts +++ b/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts @@ -22,6 +22,7 @@ class WebSocketServerWorker extends ClusterWorker { 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}/` -- 2.34.1