From 7d9756e3c95d4f46fab5f17080b107b825ec3890 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 16 Aug 2023 16:04:38 +0200 Subject: [PATCH] refactor: cleanup object destructuration in examples MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../http-server-pool/express-hybrid/src/express-worker.ts | 4 ++-- .../http-server-pool/fastify-hybrid/src/fastify-worker.ts | 7 +++++-- .../ws-hybrid/src/websocket-server-worker.ts | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts b/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts index a8ffbcb2..56fad6d1 100644 --- a/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts +++ b/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts @@ -31,7 +31,7 @@ ClusterWorkerResponse private static readonly startExpress = ( workerData?: ClusterWorkerData ): ClusterWorkerResponse => { - const { port, workerFile, minWorkers, maxWorkers } = + const { port, workerFile, minWorkers, maxWorkers, ...poolOptions } = workerData as ClusterWorkerData ExpressWorker.requestHandlerPool = new DynamicThreadPool< @@ -41,7 +41,7 @@ ClusterWorkerResponse minWorkers ?? 1, maxWorkers ?? availableParallelism(), workerFile, - workerData + poolOptions ) const application: Express = express() diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts index 9c2cb3c5..e21eb58c 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts @@ -13,13 +13,16 @@ ClusterWorkerResponse private static readonly startFastify = async ( workerData?: ClusterWorkerData ): Promise => { - const { port } = workerData as ClusterWorkerData + const { port, ...fastifyPoolifierOptions } = workerData as ClusterWorkerData FastifyWorker.fastify = Fastify({ logger: true }) - await FastifyWorker.fastify.register(fastifyPoolifier, workerData) + await FastifyWorker.fastify.register( + fastifyPoolifier, + fastifyPoolifierOptions + ) FastifyWorker.fastify.all('/api/echo', async (request) => { return ( diff --git a/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts b/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts index 7b4aa070..437fae1b 100644 --- a/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts +++ b/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts @@ -31,7 +31,7 @@ ClusterWorkerResponse private static readonly startWebSocketServer = ( workerData?: ClusterWorkerData ): ClusterWorkerResponse => { - const { port, workerFile, minWorkers, maxWorkers } = + const { port, workerFile, minWorkers, maxWorkers, ...poolOptions } = workerData as ClusterWorkerData WebSocketServerWorker.requestHandlerPool = new DynamicThreadPool< @@ -41,7 +41,7 @@ ClusterWorkerResponse minWorkers ?? 1, maxWorkers ?? availableParallelism(), workerFile, - workerData + poolOptions ) WebSocketServerWorker.wss = new WebSocketServer({ port }, () => { -- 2.34.1