From: Jérôme Benoit Date: Sat, 12 Aug 2023 17:35:46 +0000 (+0200) Subject: refactor: prepare examples for cluster pool ones X-Git-Tag: v2.6.25~16 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d2bc8d8026164b1389822feced0f42af20552176;p=poolifier.git refactor: prepare examples for cluster pool ones Signed-off-by: Jérôme Benoit --- diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bc1d7c63..a90c3e1e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -45,7 +45,7 @@ updates: - 'jerome-benoit' versioning-strategy: increase - package-ecosystem: 'npm' - directory: '/examples/typescript/http-server-pool/express' + directory: '/examples/typescript/http-server-pool/express-worker_threads' schedule: interval: 'daily' labels: @@ -57,7 +57,7 @@ updates: - 'jerome-benoit' versioning-strategy: increase - package-ecosystem: 'npm' - directory: '/examples/typescript/http-server-pool/fastify' + directory: '/examples/typescript/http-server-pool/fastify-worker_threads' schedule: interval: 'daily' labels: @@ -69,7 +69,19 @@ updates: - 'jerome-benoit' versioning-strategy: increase - package-ecosystem: 'npm' - directory: '/examples/typescript/websocket-server-pool/ws' + directory: '/examples/typescript/http-server-pool/fastify-cluster' + schedule: + interval: 'daily' + labels: + - 'dependencies' + - 'examples' + - 'nocombine' + reviewers: + - 'pioardi' + - 'jerome-benoit' + versioning-strategy: increase + - package-ecosystem: 'npm' + directory: '/examples/typescript/websocket-server-pool/ws-worker_threads' schedule: interval: 'daily' labels: diff --git a/README.md b/README.md index 6bc99e57..dae42f96 100644 --- a/README.md +++ b/README.md @@ -147,10 +147,11 @@ You can do the same with the classes _ClusterWorker_, _FixedClusterPool_ and _Dy - [Typescript](./examples/typescript/) - [HTTP client pool](./examples/typescript/http-client-pool/) - [HTTP server pool](./examples/typescript/http-server-pool/) - - [Express](./examples/typescript/http-server-pool/express/) - - [Fastify](./examples/typescript/http-server-pool/fastify/) + - [Express worker_threads pool](./examples/typescript/http-server-pool/express-worker_threads/) + - [Fastify worker_threads pool](./examples/typescript/http-server-pool/fastify-worker_threads/) + - [Fastify cluster pool](./examples/typescript/http-server-pool/fastify-cluster/) - [WebSocket server pool](./examples/typescript/websocket-server-pool/) - - [ws](./examples/typescript/websocket-server-pool/ws/) + - [ws worker_threads pool](./examples/typescript/websocket-server-pool/ws-worker_threads/) Remember that workers can only send and receive structured-cloneable data. diff --git a/examples/typescript/http-client-pool/package.json b/examples/typescript/http-client-pool/package.json index eebd1fed..c94197ff 100644 --- a/examples/typescript/http-client-pool/package.json +++ b/examples/typescript/http-client-pool/package.json @@ -22,7 +22,7 @@ "dependencies": { "axios": "^1.4.0", "node-fetch": "^3.3.2", - "poolifier": "^2.6.23" + "poolifier": "^2.6.24" }, "devDependencies": { "@types/node": "^20.4.10", diff --git a/examples/typescript/http-client-pool/pnpm-lock.yaml b/examples/typescript/http-client-pool/pnpm-lock.yaml index 63f6cc16..1f832cc2 100644 --- a/examples/typescript/http-client-pool/pnpm-lock.yaml +++ b/examples/typescript/http-client-pool/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^3.3.2 version: 3.3.2 poolifier: - specifier: ^2.6.23 - version: 2.6.23 + specifier: ^2.6.24 + version: 2.6.24 devDependencies: '@types/node': @@ -120,8 +120,8 @@ packages: formdata-polyfill: 4.0.10 dev: false - /poolifier@2.6.23: - resolution: {integrity: sha512-QQagtUD4DCzeEEq2SjoxDRsPLqr5qzJm3Wur29rWDepG935BXlGHVZLFlqUoaHXkcILIBKvLxEFs+SB2Op4TIw==} + /poolifier@2.6.24: + resolution: {integrity: sha512-3sofqoocsvz7R6LshWJ1FvnjCsHdKytw29gsrVB7AJ0d7jVuE6dMd7ax2O0U03hg+yhxpeBXOaUGO025b40kjA==} engines: {node: '>=16.14.0', pnpm: '>=8.6.0'} requiresBuild: true dev: false diff --git a/examples/typescript/http-server-pool/express/package.json b/examples/typescript/http-server-pool/express-worker_threads/package.json similarity index 96% rename from examples/typescript/http-server-pool/express/package.json rename to examples/typescript/http-server-pool/express-worker_threads/package.json index 766ec0e7..da129840 100644 --- a/examples/typescript/http-server-pool/express/package.json +++ b/examples/typescript/http-server-pool/express-worker_threads/package.json @@ -20,7 +20,7 @@ "license": "ISC", "dependencies": { "express": "^4.18.2", - "poolifier": "^2.6.23" + "poolifier": "^2.6.24" }, "devDependencies": { "@types/express": "^4.17.17", diff --git a/examples/typescript/http-server-pool/express/pnpm-lock.yaml b/examples/typescript/http-server-pool/express-worker_threads/pnpm-lock.yaml similarity index 98% rename from examples/typescript/http-server-pool/express/pnpm-lock.yaml rename to examples/typescript/http-server-pool/express-worker_threads/pnpm-lock.yaml index 4d9a3e8c..6a6cfbb4 100644 --- a/examples/typescript/http-server-pool/express/pnpm-lock.yaml +++ b/examples/typescript/http-server-pool/express-worker_threads/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^4.18.2 version: 4.18.2 poolifier: - specifier: ^2.6.23 - version: 2.6.23 + specifier: ^2.6.24 + version: 2.6.24 devDependencies: '@types/express': @@ -385,8 +385,8 @@ packages: resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} dev: false - /poolifier@2.6.23: - resolution: {integrity: sha512-QQagtUD4DCzeEEq2SjoxDRsPLqr5qzJm3Wur29rWDepG935BXlGHVZLFlqUoaHXkcILIBKvLxEFs+SB2Op4TIw==} + /poolifier@2.6.24: + resolution: {integrity: sha512-3sofqoocsvz7R6LshWJ1FvnjCsHdKytw29gsrVB7AJ0d7jVuE6dMd7ax2O0U03hg+yhxpeBXOaUGO025b40kjA==} engines: {node: '>=16.14.0', pnpm: '>=8.6.0'} requiresBuild: true dev: false diff --git a/examples/typescript/http-server-pool/express/requests.sh b/examples/typescript/http-server-pool/express-worker_threads/requests.sh similarity index 100% rename from examples/typescript/http-server-pool/express/requests.sh rename to examples/typescript/http-server-pool/express-worker_threads/requests.sh diff --git a/examples/typescript/http-server-pool/express/src/main.ts b/examples/typescript/http-server-pool/express-worker_threads/src/main.ts similarity index 100% rename from examples/typescript/http-server-pool/express/src/main.ts rename to examples/typescript/http-server-pool/express-worker_threads/src/main.ts diff --git a/examples/typescript/http-server-pool/express/src/pool.ts b/examples/typescript/http-server-pool/express-worker_threads/src/pool.ts similarity index 100% rename from examples/typescript/http-server-pool/express/src/pool.ts rename to examples/typescript/http-server-pool/express-worker_threads/src/pool.ts diff --git a/examples/typescript/http-server-pool/express/src/types.ts b/examples/typescript/http-server-pool/express-worker_threads/src/types.ts similarity index 100% rename from examples/typescript/http-server-pool/express/src/types.ts rename to examples/typescript/http-server-pool/express-worker_threads/src/types.ts diff --git a/examples/typescript/http-server-pool/express/src/worker.ts b/examples/typescript/http-server-pool/express-worker_threads/src/worker.ts similarity index 100% rename from examples/typescript/http-server-pool/express/src/worker.ts rename to examples/typescript/http-server-pool/express-worker_threads/src/worker.ts diff --git a/examples/typescript/http-server-pool/express/tsconfig.json b/examples/typescript/http-server-pool/express-worker_threads/tsconfig.json similarity index 100% rename from examples/typescript/http-server-pool/express/tsconfig.json rename to examples/typescript/http-server-pool/express-worker_threads/tsconfig.json diff --git a/examples/typescript/http-server-pool/fastify/@types/fastify/index.d.ts b/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts similarity index 100% rename from examples/typescript/http-server-pool/fastify/@types/fastify/index.d.ts rename to examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts diff --git a/examples/typescript/http-server-pool/fastify/package.json b/examples/typescript/http-server-pool/fastify-worker_threads/package.json similarity index 89% rename from examples/typescript/http-server-pool/fastify/package.json rename to examples/typescript/http-server-pool/fastify-worker_threads/package.json index 4c598823..2d7ab998 100644 --- a/examples/typescript/http-server-pool/fastify/package.json +++ b/examples/typescript/http-server-pool/fastify-worker_threads/package.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/package", "name": "fastify-plugin-request-pool", "version": "1.0.0", - "description": "fastify plugin request pool", + "description": "Fastify plugin request pool", "main": "dist/main.js", "type": "module", "volta": { @@ -21,7 +21,7 @@ "dependencies": { "fastify": "^4.21.0", "fastify-plugin": "^4.5.1", - "poolifier": "^2.6.23" + "poolifier": "^2.6.24" }, "devDependencies": { "@types/node": "^20.4.10", diff --git a/examples/typescript/http-server-pool/fastify/pnpm-lock.yaml b/examples/typescript/http-server-pool/fastify-worker_threads/pnpm-lock.yaml similarity index 98% rename from examples/typescript/http-server-pool/fastify/pnpm-lock.yaml rename to examples/typescript/http-server-pool/fastify-worker_threads/pnpm-lock.yaml index 68ddd9f3..ef021a87 100644 --- a/examples/typescript/http-server-pool/fastify/pnpm-lock.yaml +++ b/examples/typescript/http-server-pool/fastify-worker_threads/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^4.5.1 version: 4.5.1 poolifier: - specifier: ^2.6.23 - version: 2.6.23 + specifier: ^2.6.24 + version: 2.6.24 devDependencies: '@types/node': @@ -288,8 +288,8 @@ packages: thread-stream: 2.4.0 dev: false - /poolifier@2.6.23: - resolution: {integrity: sha512-QQagtUD4DCzeEEq2SjoxDRsPLqr5qzJm3Wur29rWDepG935BXlGHVZLFlqUoaHXkcILIBKvLxEFs+SB2Op4TIw==} + /poolifier@2.6.24: + resolution: {integrity: sha512-3sofqoocsvz7R6LshWJ1FvnjCsHdKytw29gsrVB7AJ0d7jVuE6dMd7ax2O0U03hg+yhxpeBXOaUGO025b40kjA==} engines: {node: '>=16.14.0', pnpm: '>=8.6.0'} requiresBuild: true dev: false diff --git a/examples/typescript/http-server-pool/fastify/requests.sh b/examples/typescript/http-server-pool/fastify-worker_threads/requests.sh similarity index 100% rename from examples/typescript/http-server-pool/fastify/requests.sh rename to examples/typescript/http-server-pool/fastify-worker_threads/requests.sh diff --git a/examples/typescript/http-server-pool/fastify/src/fastify-poolifier.ts b/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 8419e781..15e5656b 100644 --- a/examples/typescript/http-server-pool/fastify/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts @@ -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 = ( if (!fastify.hasDecorator('execute')) { fastify.decorate( 'execute', - async (data?: WorkerData, name?: string): Promise => - await pool.execute(data, name) + async ( + data?: WorkerData, + name?: string, + transferList?: TransferListItem[] + ): Promise => await pool.execute(data, name, transferList) ) } done() diff --git a/examples/typescript/http-server-pool/fastify/src/main.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts similarity index 100% rename from examples/typescript/http-server-pool/fastify/src/main.ts rename to examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts diff --git a/examples/typescript/http-server-pool/fastify/src/types.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/types.ts similarity index 100% rename from examples/typescript/http-server-pool/fastify/src/types.ts rename to examples/typescript/http-server-pool/fastify-worker_threads/src/types.ts diff --git a/examples/typescript/http-server-pool/fastify/src/worker.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/worker.ts similarity index 100% rename from examples/typescript/http-server-pool/fastify/src/worker.ts rename to examples/typescript/http-server-pool/fastify-worker_threads/src/worker.ts diff --git a/examples/typescript/http-server-pool/fastify/tsconfig.json b/examples/typescript/http-server-pool/fastify-worker_threads/tsconfig.json similarity index 100% rename from examples/typescript/http-server-pool/fastify/tsconfig.json rename to examples/typescript/http-server-pool/fastify-worker_threads/tsconfig.json diff --git a/examples/typescript/websocket-server-pool/ws/package.json b/examples/typescript/websocket-server-pool/ws-worker_threads/package.json similarity index 96% rename from examples/typescript/websocket-server-pool/ws/package.json rename to examples/typescript/websocket-server-pool/ws-worker_threads/package.json index 9368c4e0..5f7414d0 100644 --- a/examples/typescript/websocket-server-pool/ws/package.json +++ b/examples/typescript/websocket-server-pool/ws-worker_threads/package.json @@ -19,7 +19,7 @@ "author": "", "license": "ISC", "dependencies": { - "poolifier": "^2.6.23", + "poolifier": "^2.6.24", "ws": "^8.13.0" }, "devDependencies": { diff --git a/examples/typescript/websocket-server-pool/ws/pnpm-lock.yaml b/examples/typescript/websocket-server-pool/ws-worker_threads/pnpm-lock.yaml similarity index 92% rename from examples/typescript/websocket-server-pool/ws/pnpm-lock.yaml rename to examples/typescript/websocket-server-pool/ws-worker_threads/pnpm-lock.yaml index 61600d6e..a38d44d3 100644 --- a/examples/typescript/websocket-server-pool/ws/pnpm-lock.yaml +++ b/examples/typescript/websocket-server-pool/ws-worker_threads/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: poolifier: - specifier: ^2.6.23 - version: 2.6.23 + specifier: ^2.6.24 + version: 2.6.24 ws: specifier: ^8.13.0 version: 8.13.0(bufferutil@4.0.7)(utf-8-validate@6.0.3) @@ -57,8 +57,8 @@ packages: requiresBuild: true dev: false - /poolifier@2.6.23: - resolution: {integrity: sha512-QQagtUD4DCzeEEq2SjoxDRsPLqr5qzJm3Wur29rWDepG935BXlGHVZLFlqUoaHXkcILIBKvLxEFs+SB2Op4TIw==} + /poolifier@2.6.24: + resolution: {integrity: sha512-3sofqoocsvz7R6LshWJ1FvnjCsHdKytw29gsrVB7AJ0d7jVuE6dMd7ax2O0U03hg+yhxpeBXOaUGO025b40kjA==} engines: {node: '>=16.14.0', pnpm: '>=8.6.0'} requiresBuild: true dev: false diff --git a/examples/typescript/websocket-server-pool/ws/requests.js b/examples/typescript/websocket-server-pool/ws-worker_threads/requests.js similarity index 100% rename from examples/typescript/websocket-server-pool/ws/requests.js rename to examples/typescript/websocket-server-pool/ws-worker_threads/requests.js diff --git a/examples/typescript/websocket-server-pool/ws/src/main.ts b/examples/typescript/websocket-server-pool/ws-worker_threads/src/main.ts similarity index 100% rename from examples/typescript/websocket-server-pool/ws/src/main.ts rename to examples/typescript/websocket-server-pool/ws-worker_threads/src/main.ts diff --git a/examples/typescript/websocket-server-pool/ws/src/pool.ts b/examples/typescript/websocket-server-pool/ws-worker_threads/src/pool.ts similarity index 100% rename from examples/typescript/websocket-server-pool/ws/src/pool.ts rename to examples/typescript/websocket-server-pool/ws-worker_threads/src/pool.ts diff --git a/examples/typescript/websocket-server-pool/ws/src/types.ts b/examples/typescript/websocket-server-pool/ws-worker_threads/src/types.ts similarity index 100% rename from examples/typescript/websocket-server-pool/ws/src/types.ts rename to examples/typescript/websocket-server-pool/ws-worker_threads/src/types.ts diff --git a/examples/typescript/websocket-server-pool/ws/src/worker.ts b/examples/typescript/websocket-server-pool/ws-worker_threads/src/worker.ts similarity index 100% rename from examples/typescript/websocket-server-pool/ws/src/worker.ts rename to examples/typescript/websocket-server-pool/ws-worker_threads/src/worker.ts diff --git a/examples/typescript/websocket-server-pool/ws/tsconfig.json b/examples/typescript/websocket-server-pool/ws-worker_threads/tsconfig.json similarity index 100% rename from examples/typescript/websocket-server-pool/ws/tsconfig.json rename to examples/typescript/websocket-server-pool/ws-worker_threads/tsconfig.json