From: Jérôme Benoit Date: Fri, 30 Aug 2024 15:37:37 +0000 (+0200) Subject: docs: add `mapExecute` implementation to fastify examples plugin X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3924d83878275190248eb13b8f814b82c7dde655;p=poolifier.git docs: add `mapExecute` implementation to fastify examples plugin Signed-off-by: Jérôme Benoit --- 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 ece9b8cf..22a55053 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 @@ -45,6 +45,17 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( await pool.execute(data, name, transferList) ) } + if (!fastify.hasDecorator('mapExecute')) { + fastify.decorate( + 'mapExecute', + async ( + data: Iterable, + name?: string, + transferList?: readonly TransferListItem[] + ): Promise => + await pool.mapExecute(data, name, transferList) + ) + } done() } 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 a9156566..0a92fe09 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 @@ -44,6 +44,17 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( ): Promise => await pool.execute(data, name, transferList) ) } + if (!fastify.hasDecorator('mapExecute')) { + fastify.decorate( + 'mapExecute', + async ( + data: Iterable, + name?: string, + transferList?: readonly TransferListItem[] + ): Promise => + await pool.mapExecute(data, name, transferList) + ) + } done() }