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=ef083f7bb73616d1bd9d9069471edcf6dbaec0c7;hp=38c808a0cc2b223239f4ad78a7fb48ad20c8b049;hpb=5daad283d56413b7287cca894637a35e51a1222c;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 38c808a0..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,11 +40,6 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( ): Promise => await pool.execute(data, name, transferList) ) } - if (!fastify.hasDecorator('listTaskFunctions')) { - fastify.decorate('listTaskFunctions', (): string[] => - pool.listTaskFunctions() - ) - } done() }