X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-server-pool%2Ffastify-worker_threads%2Fsrc%2Ffastify-poolifier.ts;h=aa9a6d1459813c6a4cf66f0d2ce9795db5b63288;hb=af8373bb29994d0799ca0daa4b7ea85a5582d23e;hp=50668da031705190e5f7611870c51fb2f5fffc7f;hpb=93b097acefb8dfea7259bff4cb9f6c337d34db94;p=poolifier.git 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 50668da0..aa9a6d14 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 @@ -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 as number, + maxWorkers as number, + workerFile, + poolOptions ) if (!fastify.hasDecorator('pool')) { fastify.decorate('pool', pool) @@ -39,6 +40,7 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( ): Promise => await pool.execute(data, name, transferList) ) } + done() } export const fastifyPoolifier = fp(fastifyPoolifierPlugin, {