## Node versions
-You can use node versions 12.x, 13.x, 14.x
+You can use node versions 12.x, 13.x, 14.x, 16.x
## API
### `pool = new FixedThreadPool/FixedClusterPool(numberOfThreads/numberOfWorkers, filePath, opts)`
-`numberOfThreads/numberOfWorkers` (mandatory) Num of workers for this worker pool
+`numberOfThreads/numberOfWorkers` (mandatory) Number of workers for this pool
`filePath` (mandatory) Path to a file with a worker implementation
-`opts` (optional) An object with these properties :
+`opts` (optional) An object with these properties:
-- `errorHandler` - A function that will listen for error event on each worker
-- `onlineHandler` - A function that will listen for online event on each worker
-- `exitHandler` - A function that will listen for exit event on each worker
+- `errorHandler` (optional) - A function that will listen for error event on each worker
+- `onlineHandler` (optional) - A function that will listen for online event on each worker
+- `exitHandler` (optional) - A function that will listen for exit event on each worker
+- `workerChoiceStrategy` (optional) - The work choice strategy to use in this pool:
+ - `WorkerChoiceStrategies.ROUND_ROBIN`: Submit tasks to worker in this pool in a round robbin fashion
+ - `WorkerChoiceStrategies.LESS_RECENTLY_USED`: Submit tasks to the less recently used worker in the pool
+
+ Default: `WorkerChoiceStrategies.ROUND_ROBIN`
+- `enableEvents` (optional) - Events emission enablement in this pool. Default: true
### `pool = new DynamicThreadPool/DynamicClusterPool(min, max, filePath, opts)`
### `pool.execute(data)`
-Execute method is available on both pool implementations (return type : Promise):
+Execute method is available on both pool implementations (return type: Promise):
`data` (mandatory) An object that you want to pass to your worker implementation
### `pool.destroy()`
- `async` - true/false, true if your function contains async pieces else false
- `killBehavior` - Dictates if your async unit (worker/process) will be deleted in case that a task is active on it.
- **SOFT**: If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still running, then the worker **won't** be deleted.
- **HARD**: If `lastActiveTime` is greater than `maxInactiveTime` but a task is still running, then the worker will be deleted.
+ **KillBehaviors.SOFT**: If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still running, then the worker **won't** be deleted.
+ **KillBehaviors.HARD**: If `lastActiveTime` is greater than `maxInactiveTime` but a task is still running, then the worker will be deleted.
This option only apply to the newly created workers.
- Default: `SOFT`
+ Default: `KillBehaviors.SOFT`
## General guidance
}
},
"@es-joy/jsdoccomment": {
- "version": "0.1.1",
- "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.1.1.tgz",
- "integrity": "sha512-6lIx5Pjc50D7VJU9lfRZ1twfIrIwQk+aeT9Ink2C07IUu/y9pxkIpDqmhY/VN3jAW42dA5z6ioOdyhOZZU1isw==",
- "dev": true
+ "version": "0.4.3",
+ "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.4.3.tgz",
+ "integrity": "sha512-t0JWZfQiG+Qkr6+tl05dlGcgE/MMPqs7QfNlFkTsbpcCu2Zfukcan/fIiHKTc0iOs4Yh3cnfklMayJnlmKaOwQ==",
+ "dev": true,
+ "requires": {
+ "comment-parser": "^1.1.5",
+ "esquery": "^1.4.0",
+ "jsdoctypeparser": "^9.0.0"
+ }
},
"@eslint/eslintrc": {
- "version": "0.4.0",
- "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.0.tgz",
- "integrity": "sha512-2ZPCc+uNbjV5ERJr+aKSPRwZgKd2z11x0EgLvb1PURmUrn9QNRXFqje0Ldq454PfAVyaJYyrDvvIKSFP4NnBog==",
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.1.tgz",
+ "integrity": "sha512-5v7TDE9plVhvxQeWLXDTvFvJBdH6pEsdnl2g/dAptmuFEPedQ4Erq5rsDsX+mvAM610IhNaO2W5V1dOOnDKxkQ==",
"dev": true,
"requires": {
"ajv": "^6.12.4",
"dev": true
},
"@types/node": {
- "version": "14.14.43",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.43.tgz",
- "integrity": "sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ==",
+ "version": "14.14.44",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.44.tgz",
+ "integrity": "sha512-+gaugz6Oce6ZInfI/tK4Pq5wIIkJMEJUu92RB3Eu93mtj4wjjjz9EB5mLp5s1pSsLXdC/CPut/xF20ZzAQJbTA==",
"dev": true
},
"@types/parse-json": {
"dev": true
},
"@typescript-eslint/eslint-plugin": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.0.tgz",
- "integrity": "sha512-U8SP9VOs275iDXaL08Ln1Fa/wLXfj5aTr/1c0t0j6CdbOnxh+TruXu1p4I0NAvdPBQgoPjHsgKn28mOi0FzfoA==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.1.tgz",
+ "integrity": "sha512-kVTAghWDDhsvQ602tHBc6WmQkdaYbkcTwZu+7l24jtJiYvm9l+/y/b2BZANEezxPDiX5MK2ZecE+9BFi/YJryw==",
"dev": true,
"requires": {
- "@typescript-eslint/experimental-utils": "4.22.0",
- "@typescript-eslint/scope-manager": "4.22.0",
+ "@typescript-eslint/experimental-utils": "4.22.1",
+ "@typescript-eslint/scope-manager": "4.22.1",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"lodash": "^4.17.15",
}
},
"@typescript-eslint/experimental-utils": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.0.tgz",
- "integrity": "sha512-xJXHHl6TuAxB5AWiVrGhvbGL8/hbiCQ8FiWwObO3r0fnvBdrbWEDy1hlvGQOAWc6qsCWuWMKdVWlLAEMpxnddg==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.1.tgz",
+ "integrity": "sha512-svYlHecSMCQGDO2qN1v477ax/IDQwWhc7PRBiwAdAMJE7GXk5stF4Z9R/8wbRkuX/5e9dHqbIWxjeOjckK3wLQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
- "@typescript-eslint/scope-manager": "4.22.0",
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/typescript-estree": "4.22.0",
+ "@typescript-eslint/scope-manager": "4.22.1",
+ "@typescript-eslint/types": "4.22.1",
+ "@typescript-eslint/typescript-estree": "4.22.1",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
}
},
"@typescript-eslint/parser": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.22.0.tgz",
- "integrity": "sha512-z/bGdBJJZJN76nvAY9DkJANYgK3nlRstRRi74WHm3jjgf2I8AglrSY+6l7ogxOmn55YJ6oKZCLLy+6PW70z15Q==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.22.1.tgz",
+ "integrity": "sha512-l+sUJFInWhuMxA6rtirzjooh8cM/AATAe3amvIkqKFeMzkn85V+eLzb1RyuXkHak4dLfYzOmF6DXPyflJvjQnw==",
"dev": true,
"requires": {
- "@typescript-eslint/scope-manager": "4.22.0",
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/typescript-estree": "4.22.0",
+ "@typescript-eslint/scope-manager": "4.22.1",
+ "@typescript-eslint/types": "4.22.1",
+ "@typescript-eslint/typescript-estree": "4.22.1",
"debug": "^4.1.1"
}
},
"@typescript-eslint/scope-manager": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.22.0.tgz",
- "integrity": "sha512-OcCO7LTdk6ukawUM40wo61WdeoA7NM/zaoq1/2cs13M7GyiF+T4rxuA4xM+6LeHWjWbss7hkGXjFDRcKD4O04Q==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.22.1.tgz",
+ "integrity": "sha512-d5bAiPBiessSmNi8Amq/RuLslvcumxLmyhf1/Xa9IuaoFJ0YtshlJKxhlbY7l2JdEk3wS0EnmnfeJWSvADOe0g==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/visitor-keys": "4.22.0"
+ "@typescript-eslint/types": "4.22.1",
+ "@typescript-eslint/visitor-keys": "4.22.1"
}
},
"@typescript-eslint/types": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.22.0.tgz",
- "integrity": "sha512-sW/BiXmmyMqDPO2kpOhSy2Py5w6KvRRsKZnV0c4+0nr4GIcedJwXAq+RHNK4lLVEZAJYFltnnk1tJSlbeS9lYA==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.22.1.tgz",
+ "integrity": "sha512-2HTkbkdAeI3OOcWbqA8hWf/7z9c6gkmnWNGz0dKSLYLWywUlkOAQ2XcjhlKLj5xBFDf8FgAOF5aQbnLRvgNbCw==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.0.tgz",
- "integrity": "sha512-TkIFeu5JEeSs5ze/4NID+PIcVjgoU3cUQUIZnH3Sb1cEn1lBo7StSV5bwPuJQuoxKXlzAObjYTilOEKRuhR5yg==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.1.tgz",
+ "integrity": "sha512-p3We0pAPacT+onSGM+sPR+M9CblVqdA9F1JEdIqRVlxK5Qth4ochXQgIyb9daBomyQKAXbygxp1aXQRV0GC79A==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/visitor-keys": "4.22.0",
+ "@typescript-eslint/types": "4.22.1",
+ "@typescript-eslint/visitor-keys": "4.22.1",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
}
},
"@typescript-eslint/visitor-keys": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.0.tgz",
- "integrity": "sha512-nnMu4F+s4o0sll6cBSsTeVsT4cwxB7zECK3dFxzEjPBii9xLpq4yqqsy/FU5zMfan6G60DKZSCXAa3sHJZrcYw==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.1.tgz",
+ "integrity": "sha512-WPkOrIRm+WCLZxXQHCi+WG8T2MMTUFR70rWjdWYddLT7cEfb2P4a3O/J2U1FBVsSFTocXLCoXWY6MZGejeStvQ==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.22.0",
+ "@typescript-eslint/types": "4.22.1",
"eslint-visitor-keys": "^2.0.0"
}
},
}
},
"anymatch": {
- "version": "3.1.1",
- "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz",
- "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==",
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
+ "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==",
"dev": true,
"requires": {
"normalize-path": "^3.0.0",
"dev": true
},
"eslint": {
- "version": "7.25.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.25.0.tgz",
- "integrity": "sha512-TVpSovpvCNpLURIScDRB6g5CYu/ZFq9GfX2hLNIV4dSBKxIWojeDODvYl3t0k0VtMxYeR8OXPCFE5+oHMlGfhw==",
+ "version": "7.26.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.26.0.tgz",
+ "integrity": "sha512-4R1ieRf52/izcZE7AlLy56uIHHDLT74Yzz2Iv2l6kDaYvEu9x+wMB5dZArVL8SYGXSYV2YAg70FcW5Y5nGGNIg==",
"dev": true,
"requires": {
"@babel/code-frame": "7.12.11",
- "@eslint/eslintrc": "^0.4.0",
+ "@eslint/eslintrc": "^0.4.1",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
}
},
"eslint-plugin-jsdoc": {
- "version": "33.0.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-33.0.0.tgz",
- "integrity": "sha512-bkopnnuDdT04abKWPfDdD6XcAp2yX6UDpDViyvIdYmxbZYbpHXCRzQzLqCTo+SzWSTS0KFWz/V3shmmMr+x4EA==",
+ "version": "33.1.0",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-33.1.0.tgz",
+ "integrity": "sha512-nyH1qAj5f4uDnDpg4aiAS65wJSfxfBDf0lIgNfxtew31z3VRaM8WsVmpe4UhI2u27oOD/ChRuye6KAzzuHn6Jw==",
"dev": true,
"requires": {
- "@es-joy/jsdoccomment": "^0.1.1",
+ "@es-joy/jsdoccomment": "^0.4.3",
"comment-parser": "1.1.5",
"debug": "^4.3.1",
+ "esquery": "^1.4.0",
"jsdoctypeparser": "^9.0.0",
"lodash": "^4.17.21",
"regextras": "^0.7.1",
"dev": true
},
"hosted-git-info": {
- "version": "2.8.8",
- "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
- "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==",
+ "version": "2.8.9",
+ "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
+ "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true
},
"html-element-attributes": {
"integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=",
"dev": true
},
- "lodash.flatten": {
- "version": "4.4.0",
- "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz",
- "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=",
- "dev": true
- },
"lodash.flattendeep": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz",
"dev": true
},
"mocha": {
- "version": "8.3.2",
- "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.3.2.tgz",
- "integrity": "sha512-UdmISwr/5w+uXLPKspgoV7/RXZwKRTiTjJ2/AC5ZiEztIoOYdfKb19+9jNmEInzx5pBsCyJQzarAxqIGBNYJhg==",
+ "version": "8.4.0",
+ "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz",
+ "integrity": "sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ==",
"dev": true,
"requires": {
"@ungap/promise-all-settled": "1.1.2",
}
},
"prettier-plugin-organize-imports": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-1.1.1.tgz",
- "integrity": "sha512-rFA1lnek1FYkMGthm4xBKME41qUKItTovuo24bCGZu/Vu1n3gW71UPLAkIdwewwkZCe29gRVweSOPXvAdckFuw==",
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-2.0.0.tgz",
+ "integrity": "sha512-jPSE5sqFAu+lyKqwcN4zlSHaZmI6/3sJ2F+BkKn7iGCwNdPba1FPUJrx5bPzWnGyrQwGKQZYCuHgVQlCzohing==",
"dev": true
},
"prettierx": {
}
},
"rollup": {
- "version": "2.46.0",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.46.0.tgz",
- "integrity": "sha512-qPGoUBNl+Z8uNu0z7pD3WPTABWRbcOwIrO/5ccDJzmrtzn0LVf6Lj91+L5CcWhXl6iWf23FQ6m8Jkl2CmN1O7Q==",
+ "version": "2.47.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.47.0.tgz",
+ "integrity": "sha512-rqBjgq9hQfW0vRmz+0S062ORRNJXvwRpzxhFXORvar/maZqY6za3rgQ/p1Glg+j1hnc1GtYyQCPiAei95uTElg==",
"dev": true,
"requires": {
"fsevents": "~2.3.1"
}
},
"table": {
- "version": "6.5.1",
- "resolved": "https://registry.npmjs.org/table/-/table-6.5.1.tgz",
- "integrity": "sha512-xGDXWTBJxahkzPQCsn1S9ESHEenU7TbMD5Iv4FeopXv/XwJyWatFjfbor+6ipI10/MNPXBYUamYukOrbPZ9L/w==",
+ "version": "6.7.0",
+ "resolved": "https://registry.npmjs.org/table/-/table-6.7.0.tgz",
+ "integrity": "sha512-SAM+5p6V99gYiiy2gT5ArdzgM1dLDed0nkrWmG6Fry/bUS/m9x83BwpJUOf1Qj/x2qJd+thL6IkIx7qPGRxqBw==",
"dev": true,
"requires": {
"ajv": "^8.0.1",
"lodash.clonedeep": "^4.5.0",
- "lodash.flatten": "^4.4.0",
"lodash.truncate": "^4.4.2",
"slice-ansi": "^4.0.0",
"string-width": "^4.2.0",
},
"dependencies": {
"ajv": {
- "version": "8.1.0",
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.1.0.tgz",
- "integrity": "sha512-B/Sk2Ix7A36fs/ZkuGLIR86EdjbgR6fsAcbx9lOP/QBSXujDNbVmIS/U4Itz5k8fPFDeVZl/zQ/gJW4Jrq6XjQ==",
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.2.0.tgz",
+ "integrity": "sha512-WSNGFuyWd//XO8n/m/EaOlNLtO0yL8EXT/74LqT4khdhpZjP7lkj/kT5uwRmGitKEVp/Oj7ZUHeGfPtgHhQ5CA==",
"dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
"dev": true
},
"y18n": {
- "version": "5.0.5",
- "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz",
- "integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==",
+ "version": "5.0.8",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
+ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
"dev": true
},
"yallist": {