From: Jérôme Benoit Date: Wed, 16 Aug 2023 14:04:38 +0000 (+0200) Subject: refactor: cleanup object destructuration in examples X-Git-Tag: v2.6.28~10 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7d9756e3c95d4f46fab5f17080b107b825ec3890;p=poolifier.git refactor: cleanup object destructuration in examples Signed-off-by: Jérôme Benoit --- 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 }, () => {