Skip to content

Commit 295322e

Browse files
authored
Merge pull request #40 from razvancurcudel/master
set and get for nMaxWorkersCount
2 parents 97e57f9 + 22314d8 commit 295322e

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
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: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ class MasterEndpoint extends JSONRPC.EndpointBase
7070
}
7171

7272

73+
/**
74+
* @param {number} nWorkersCount
75+
*/
76+
set maxWorkersCount(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 maxWorkersCount()
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.maxWorkersCount); i++)
191211
{
192212
cluster.fork();
193213
}

0 commit comments

Comments
 (0)