poolifier 2.5.3 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -25
- package/lib/index.d.ts +8 -9
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/pools/abstract-pool.d.ts +10 -16
- package/lib/pools/cluster/fixed.d.ts +1 -3
- package/lib/pools/pool.d.ts +3 -1
- package/lib/pools/selection-strategies/abstract-worker-choice-strategy.d.ts +19 -10
- package/lib/pools/selection-strategies/fair-share-worker-choice-strategy.d.ts +2 -2
- package/lib/pools/selection-strategies/least-busy-worker-choice-strategy.d.ts +2 -2
- package/lib/pools/selection-strategies/least-elu-worker-choice-strategy.d.ts +25 -0
- package/lib/pools/selection-strategies/selection-strategies-types.d.ts +66 -22
- package/lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.d.ts +2 -2
- package/lib/pools/selection-strategies/worker-choice-strategy-context.d.ts +4 -4
- package/lib/pools/thread/dynamic.d.ts +3 -3
- package/lib/pools/thread/fixed.d.ts +14 -4
- package/lib/pools/worker.d.ts +56 -28
- package/lib/utility-types.d.ts +50 -45
- package/lib/worker/abstract-worker.d.ts +10 -3
- package/lib/worker/cluster-worker.d.ts +2 -1
- package/lib/worker/thread-worker.d.ts +2 -1
- package/lib/worker/worker-functions.d.ts +33 -0
- package/lib/worker/worker-options.d.ts +4 -4
- package/package.json +9 -9
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker synchronous function that can be executed.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam Data - Type of data sent to the worker. This can only be serializable data.
|
|
5
|
+
* @typeParam Response - Type of execution response. This can only be serializable data.
|
|
6
|
+
*/
|
|
7
|
+
export type WorkerSyncFunction<Data = unknown, Response = unknown> = (data?: Data) => Response;
|
|
8
|
+
/**
|
|
9
|
+
* Worker asynchronous function that can be executed.
|
|
10
|
+
* This function must return a promise.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam Data - Type of data sent to the worker. This can only be serializable data.
|
|
13
|
+
* @typeParam Response - Type of execution response. This can only be serializable data.
|
|
14
|
+
*/
|
|
15
|
+
export type WorkerAsyncFunction<Data = unknown, Response = unknown> = (data?: Data) => Promise<Response>;
|
|
16
|
+
/**
|
|
17
|
+
* Worker function that can be executed.
|
|
18
|
+
* This function can be synchronous or asynchronous.
|
|
19
|
+
*
|
|
20
|
+
* @typeParam Data - Type of data sent to the worker. This can only be serializable data.
|
|
21
|
+
* @typeParam Response - Type of execution response. This can only be serializable data.
|
|
22
|
+
*/
|
|
23
|
+
export type WorkerFunction<Data = unknown, Response = unknown> = WorkerSyncFunction<Data, Response> | WorkerAsyncFunction<Data, Response>;
|
|
24
|
+
/**
|
|
25
|
+
* Worker functions that can be executed.
|
|
26
|
+
* This object can contain synchronous or asynchronous functions.
|
|
27
|
+
* The key is the name of the function.
|
|
28
|
+
* The value is the function itself.
|
|
29
|
+
*
|
|
30
|
+
* @typeParam Data - Type of data sent to the worker. This can only be serializable data.
|
|
31
|
+
* @typeParam Response - Type of execution response. This can only be serializable data.
|
|
32
|
+
*/
|
|
33
|
+
export type TaskFunctions<Data = unknown, Response = unknown> = Record<string, WorkerFunction<Data, Response>>;
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const KillBehaviors: Readonly<{
|
|
5
5
|
/**
|
|
6
|
-
* If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still
|
|
6
|
+
* If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still executing, then the worker **wont** be deleted.
|
|
7
7
|
*/
|
|
8
8
|
readonly SOFT: "SOFT";
|
|
9
9
|
/**
|
|
10
|
-
* If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still
|
|
10
|
+
* If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still executing, then the worker will be deleted.
|
|
11
11
|
*/
|
|
12
12
|
readonly HARD: "HARD";
|
|
13
13
|
}>;
|
|
@@ -51,8 +51,8 @@ export interface WorkerOptions {
|
|
|
51
51
|
/**
|
|
52
52
|
* `killBehavior` dictates if your async unit (worker/process) will be deleted in case that a task is active on it.
|
|
53
53
|
*
|
|
54
|
-
* - SOFT: If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still
|
|
55
|
-
* - HARD: If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still
|
|
54
|
+
* - SOFT: If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still executing, then the worker **won't** be deleted.
|
|
55
|
+
* - HARD: If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still executing, then the worker will be deleted.
|
|
56
56
|
*
|
|
57
57
|
* This option only apply to the newly created workers.
|
|
58
58
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poolifier",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "A fast, easy to use Node.js Worker Thread Pool and Cluster Pool implementation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"pnpm": ">=8.6.0"
|
|
26
26
|
},
|
|
27
27
|
"volta": {
|
|
28
|
-
"node": "20.
|
|
29
|
-
"pnpm": "8.6.
|
|
28
|
+
"node": "20.3.0",
|
|
29
|
+
"pnpm": "8.6.1"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"@rollup/plugin-terser": "^0.4.3",
|
|
86
86
|
"@rollup/plugin-typescript": "^11.1.1",
|
|
87
87
|
"@types/node": "^20.2.5",
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
89
|
-
"@typescript-eslint/parser": "^5.59.
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^5.59.9",
|
|
89
|
+
"@typescript-eslint/parser": "^5.59.9",
|
|
90
90
|
"benny": "^3.7.1",
|
|
91
91
|
"c8": "^7.14.0",
|
|
92
92
|
"eslint": "^8.42.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"eslint-define-config": "^1.20.0",
|
|
96
96
|
"eslint-import-resolver-typescript": "^3.5.5",
|
|
97
97
|
"eslint-plugin-import": "^2.27.5",
|
|
98
|
-
"eslint-plugin-jsdoc": "^46.2.
|
|
98
|
+
"eslint-plugin-jsdoc": "^46.2.6",
|
|
99
99
|
"eslint-plugin-n": "^16.0.0",
|
|
100
100
|
"eslint-plugin-promise": "^6.1.1",
|
|
101
101
|
"eslint-plugin-spellcheck": "^0.0.20",
|
|
@@ -107,15 +107,15 @@
|
|
|
107
107
|
"mocha": "^10.2.0",
|
|
108
108
|
"mochawesome": "^7.1.3",
|
|
109
109
|
"prettier": "^2.8.8",
|
|
110
|
-
"release-it": "^15.
|
|
111
|
-
"rollup": "^3.
|
|
110
|
+
"release-it": "^15.11.0",
|
|
111
|
+
"rollup": "^3.24.0",
|
|
112
112
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
113
113
|
"rollup-plugin-command": "^1.1.3",
|
|
114
114
|
"rollup-plugin-delete": "^2.0.0",
|
|
115
115
|
"sinon": "^15.1.0",
|
|
116
116
|
"source-map-support": "^0.5.21",
|
|
117
117
|
"ts-standard": "^12.0.2",
|
|
118
|
-
"typedoc": "^0.24.
|
|
118
|
+
"typedoc": "^0.24.8",
|
|
119
119
|
"typescript": "^5.1.3"
|
|
120
120
|
},
|
|
121
121
|
"scripts": {
|