The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [2.3.3] - 2022-15-10
+
+### Added
+
+- Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
+
## [2.3.2] - 2022-14-10
### Changed
{
"name": "poolifier",
- "version": "2.3.2",
+ "version": "2.3.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "poolifier",
- "version": "2.3.2",
+ "version": "2.3.3",
"license": "MIT",
"devDependencies": {
"@types/node": "^18.11.0",
{
"name": "poolifier",
- "version": "2.3.2",
+ "version": "2.3.3",
"description": "A fast, easy to use Node.js Worker Thread Pool and Cluster Pool implementation",
"main": "lib/index.js",
"scripts": {
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.eslint.reportPaths=reports/eslint.json
sonar.projectName=poolifier
-sonar.projectVersion=2.3.2
+sonar.projectVersion=2.3.3
sonar.host.url=https://sonarcloud.io
sonar.sources=src
sonar.tests=tests
-import type { Worker } from 'cluster'
+import type { ClusterSettings, Worker } from 'cluster'
import cluster from 'cluster'
import type { MessageValue } from '../../utility-types'
import { AbstractPool } from '../abstract-pool'
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
env?: any
+ /**
+ * Cluster settings.
+ *
+ * @see https://nodejs.org/api/cluster.html#cluster_cluster_settings
+ */
+ settings?: ClusterSettings
}
/**
/** @inheritDoc */
protected setupHook (): void {
- cluster.setupPrimary({
- exec: this.filePath
- })
+ cluster.setupPrimary({ ...this.opts.settings, exec: this.filePath })
}
/** @inheritDoc */
expect(numberOfExitEvents).toBe(numberOfWorkers)
})
+ it('Verify that cluster pool options are checked', async () => {
+ const workerFilePath = './tests/worker-files/cluster/testWorker.js'
+ let pool1 = new FixedClusterPool(numberOfWorkers, workerFilePath)
+ expect(pool1.opts.env).toBeUndefined()
+ expect(pool1.opts.settings).toBeUndefined()
+ await pool1.destroy()
+ pool1 = new FixedClusterPool(numberOfWorkers, workerFilePath, {
+ env: { TEST: 'test' },
+ settings: { args: ['--use', 'http'], silent: true }
+ })
+ expect(pool1.opts.env).toStrictEqual({ TEST: 'test' })
+ expect(pool1.opts.settings).toStrictEqual({
+ args: ['--use', 'http'],
+ silent: true
+ })
+ expect({ ...pool1.opts.settings, exec: workerFilePath }).toStrictEqual({
+ args: ['--use', 'http'],
+ silent: true,
+ exec: workerFilePath
+ })
+ await pool1.destroy()
+ })
+
it('Should work even without opts in input', async () => {
const pool1 = new FixedClusterPool(
numberOfWorkers,