refactor: prepare examples for cluster pool ones
[poolifier.git] / examples / typescript / http-server-pool / fastify-worker_threads / src / fastify-poolifier.ts
similarity index 79%
rename from examples/typescript/http-server-pool/fastify/src/fastify-poolifier.ts
rename to examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts
index 8419e78194574f3372cf17089ade2c046135b0d4..15e5656b12abe44477a65dc7efd4a994b51663d7 100644 (file)
@@ -1,3 +1,4 @@
+import type { TransferListItem } from 'worker_threads'
 import { DynamicThreadPool, availableParallelism } from 'poolifier'
 import { type FastifyPluginCallback } from 'fastify'
 import fp from 'fastify-plugin'
@@ -31,8 +32,11 @@ const fastifyPoolifierPlugin: FastifyPluginCallback<FastifyPoolifierOptions> = (
   if (!fastify.hasDecorator('execute')) {
     fastify.decorate(
       'execute',
-      async (data?: WorkerData, name?: string): Promise<WorkerResponse> =>
-        await pool.execute(data, name)
+      async (
+        data?: WorkerData,
+        name?: string,
+        transferList?: TransferListItem[]
+      ): Promise<WorkerResponse> => await pool.execute(data, name, transferList)
     )
   }
   done()