X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-server-pool%2Ffastify-hybrid%2Fsrc%2Ffastify-poolifier.ts;h=3c5e31e34dc85c9583b29ba427d8cb66704cb686;hb=8166b5b31ebb2d15bbdc112f1a86d3774fe21294;hp=6e3a1dbfec643759ef30aecfd767e5f9d1c40e02;hpb=3b3115396965edad0cf3fefc4f9081977310da34;p=poolifier.git 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..3c5e31e3 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 @@ -1,6 +1,6 @@ -import type { TransferListItem } from 'worker_threads' +import type { TransferListItem } from 'node:worker_threads' import { DynamicThreadPool, availableParallelism } from 'poolifier' -import { type FastifyPluginCallback } from 'fastify' +import type { FastifyPluginCallback } from 'fastify' import fp from 'fastify-plugin' import { type FastifyPoolifierOptions, @@ -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!, + maxWorkers!, + workerFile, + poolOptions ) if (!fastify.hasDecorator('pool')) { fastify.decorate('pool', pool)