Skip to content

Commit ca78bc0

Browse files
set and get for nMaxWorkersCount
1 parent 97e57f9 commit ca78bc0

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jsonrpc-bidirectional",
33
"description": "Bidirectional JSONRPC over web sockets or HTTP with extensive plugin support.",
4-
"version": "6.5.0",
4+
"version": "6.5.1",
55
"scripts": {
66
"build": "node build.js",
77
"test": "node --expose-gc --max-old-space-size=1024 tests/main.js",
@@ -81,4 +81,4 @@
8181
"node_modules/es6-promise/dist/es6-promise.auto.min.js",
8282
"node_modules/es6-promise/dist/es6-promise.auto.min.js.map"
8383
]
84-
}
84+
}

src/NodeClusterBase/MasterEndpoint.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class MasterEndpoint extends JSONRPC.EndpointBase
5555
this._bWorkersStarted = false;
5656
this._bWatchingForUpgrade = false;
5757

58-
this._nMaxWorkersCount = Number.MAX_SAFE_INTEGER;
58+
this.nMaxWorkersCount = Number.MAX_SAFE_INTEGER;
5959
}
6060

6161

@@ -70,6 +70,26 @@ class MasterEndpoint extends JSONRPC.EndpointBase
7070
}
7171

7272

73+
/**
74+
* @param {number} nWorkersCount
75+
*/
76+
set nMaxWorkersCount(nWorkersCount)
77+
{
78+
assert(typeof nWorkersCount === "number", `Invalid property type for nWorkersCount in MasterEndpoint. Expected "number", but got ${typeof nWorkersCount}.`);
79+
80+
this._nMaxWorkersCount = nWorkersCount;
81+
}
82+
83+
84+
/**
85+
* @returns {number}
86+
*/
87+
get nMaxWorkersCount()
88+
{
89+
return this._nMaxWorkersCount;
90+
}
91+
92+
7393
/**
7494
* This overridable function is called and awaited inside startWorker().
7595
*
@@ -187,7 +207,7 @@ class MasterEndpoint extends JSONRPC.EndpointBase
187207

188208
await this._startServices();
189209

190-
for (let i = 0; i < Math.min(Math.max(os.cpus().length, 1), this._nMaxWorkersCount); i++)
210+
for (let i = 0; i < Math.min(Math.max(os.cpus().length, 1), this.nMaxWorkersCount); i++)
191211
{
192212
cluster.fork();
193213
}

0 commit comments

Comments
 (0)