refactor: prepare examples for cluster pool ones
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 12 Aug 2023 17:35:46 +0000 (19:35 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 12 Aug 2023 17:35:46 +0000 (19:35 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
29 files changed:
.github/dependabot.yml
README.md
examples/typescript/http-client-pool/package.json
examples/typescript/http-client-pool/pnpm-lock.yaml
examples/typescript/http-server-pool/express-worker_threads/package.json [moved from examples/typescript/http-server-pool/express/package.json with 96% similarity]
examples/typescript/http-server-pool/express-worker_threads/pnpm-lock.yaml [moved from examples/typescript/http-server-pool/express/pnpm-lock.yaml with 98% similarity]
examples/typescript/http-server-pool/express-worker_threads/requests.sh [moved from examples/typescript/http-server-pool/express/requests.sh with 100% similarity]
examples/typescript/http-server-pool/express-worker_threads/src/main.ts [moved from examples/typescript/http-server-pool/express/src/main.ts with 100% similarity]
examples/typescript/http-server-pool/express-worker_threads/src/pool.ts [moved from examples/typescript/http-server-pool/express/src/pool.ts with 100% similarity]
examples/typescript/http-server-pool/express-worker_threads/src/types.ts [moved from examples/typescript/http-server-pool/express/src/types.ts with 100% similarity]
examples/typescript/http-server-pool/express-worker_threads/src/worker.ts [moved from examples/typescript/http-server-pool/express/src/worker.ts with 100% similarity]
examples/typescript/http-server-pool/express-worker_threads/tsconfig.json [moved from examples/typescript/http-server-pool/express/tsconfig.json with 100% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts [moved from examples/typescript/http-server-pool/fastify/@types/fastify/index.d.ts with 100% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/package.json [moved from examples/typescript/http-server-pool/fastify/package.json with 89% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/pnpm-lock.yaml [moved from examples/typescript/http-server-pool/fastify/pnpm-lock.yaml with 98% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/requests.sh [moved from examples/typescript/http-server-pool/fastify/requests.sh with 100% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts [moved from examples/typescript/http-server-pool/fastify/src/fastify-poolifier.ts with 79% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts [moved from examples/typescript/http-server-pool/fastify/src/main.ts with 100% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/src/types.ts [moved from examples/typescript/http-server-pool/fastify/src/types.ts with 100% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/src/worker.ts [moved from examples/typescript/http-server-pool/fastify/src/worker.ts with 100% similarity]
examples/typescript/http-server-pool/fastify-worker_threads/tsconfig.json [moved from examples/typescript/http-server-pool/fastify/tsconfig.json with 100% similarity]
examples/typescript/websocket-server-pool/ws-worker_threads/package.json [moved from examples/typescript/websocket-server-pool/ws/package.json with 96% similarity]
examples/typescript/websocket-server-pool/ws-worker_threads/pnpm-lock.yaml [moved from examples/typescript/websocket-server-pool/ws/pnpm-lock.yaml with 92% similarity]
examples/typescript/websocket-server-pool/ws-worker_threads/requests.js [moved from examples/typescript/websocket-server-pool/ws/requests.js with 100% similarity]
examples/typescript/websocket-server-pool/ws-worker_threads/src/main.ts [moved from examples/typescript/websocket-server-pool/ws/src/main.ts with 100% similarity]
examples/typescript/websocket-server-pool/ws-worker_threads/src/pool.ts [moved from examples/typescript/websocket-server-pool/ws/src/pool.ts with 100% similarity]
examples/typescript/websocket-server-pool/ws-worker_threads/src/types.ts [moved from examples/typescript/websocket-server-pool/ws/src/types.ts with 100% similarity]
examples/typescript/websocket-server-pool/ws-worker_threads/src/worker.ts [moved from examples/typescript/websocket-server-pool/ws/src/worker.ts with 100% similarity]
examples/typescript/websocket-server-pool/ws-worker_threads/tsconfig.json [moved from examples/typescript/websocket-server-pool/ws/tsconfig.json with 100% similarity]

index bc1d7c6338733faf27078f22eae0ca97292fd4b1..a90c3e1ea8dcf760a44cb2245e370f1455f0d04b 100644 (file)
@@ -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:
index 6bc99e57bc8378bf50497c0ef40dcc79353ea85d..dae42f966c92bf195337be630dcd4e06625cc3c7 100644 (file)
--- 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.
 
index eebd1feda3f2b8bbd066fdded097d755a8308521..c94197ff5603122318adccae710a27ad3b5fe8da 100644 (file)
@@ -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",
index 63f6cc16e4f6aae3c9ae62c1a6cb01312c0f603e..1f832cc20e0e61a45ff841e456e8274485fa6edd 100644 (file)
@@ -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
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 766ec0e74c59fb0a8afdf9dc0505cef301617efc..da129840433a16851dd175dd8287b0b9a9bbf7a8 100644 (file)
@@ -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",
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 4d9a3e8ca761dcf471db195266422c64e4926a95..6a6cfbb48f11903eb586baaae38b318602a8f2ee 100644 (file)
@@ -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
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 4c59882380c2267fa5424cbffd4ce0ea00d6081b..2d7ab9989f9285c43eb440f656f7f9dd94b0e6dc 100644 (file)
@@ -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",
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 68ddd9f36e450ef679127c6eed77bea10df661bc..ef021a87c929a0838979302d9829d08bdc05497f 100644 (file)
@@ -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
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()
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 9368c4e0d4d01957a5f9bd7ddc9a6a846dd22267..5f7414d08c44959a281a97dedba29c20dc9e38fd 100644 (file)
@@ -19,7 +19,7 @@
   "author": "",
   "license": "ISC",
   "dependencies": {
-    "poolifier": "^2.6.23",
+    "poolifier": "^2.6.24",
     "ws": "^8.13.0"
   },
   "devDependencies": {
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 61600d6eb44fff4266fbf11107fa2afcd40e52e2..a38d44d31d1f0aeab485dbe8018c801eced50121 100644 (file)
@@ -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