summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Tian <shyvo1987@gmail.com>2021-02-15 23:33:35 +0800
committerJackson Tian <shyvo1987@gmail.com>2021-02-15 23:33:56 +0800
commit0e2e8a9265a936945a8ed157915e7849e2ac500c (patch)
tree05fa88bf8a8b2f186b1f199700eef17940a1a0e9
parentce4798b55515827f2a68d269d0f433e3ea9828bb (diff)
downloadnode-new-improve.tar.gz
cluster: clarify construct Handleimprove
Improve the readability for costruct SharedHandle and RoundRobinHandle
-rw-r--r--lib/internal/cluster/primary.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/internal/cluster/primary.js b/lib/internal/cluster/primary.js
index e811341179..49011369ee 100644
--- a/lib/internal/cluster/primary.js
+++ b/lib/internal/cluster/primary.js
@@ -117,8 +117,7 @@ function createWorkerProcess(id, env) {
const workerEnv = { ...process.env, ...env, NODE_UNIQUE_ID: `${id}` };
const execArgv = [...cluster.settings.execArgv];
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
- const nodeOptions = process.env.NODE_OPTIONS ?
- process.env.NODE_OPTIONS : '';
+ const nodeOptions = process.env.NODE_OPTIONS || '';
if (ArrayPrototypeSome(execArgv,
(arg) => RegExpPrototypeTest(debugArgRegex, arg)) ||
@@ -302,17 +301,17 @@ function queryServer(worker, message) {
address = message.address;
}
- let constructor = RoundRobinHandle;
// UDP is exempt from round-robin connection balancing for what should
// be obvious reasons: it's connectionless. There is nothing to send to
// the workers except raw datagrams and that's pointless.
if (schedulingPolicy !== SCHED_RR ||
message.addressType === 'udp4' ||
message.addressType === 'udp6') {
- constructor = SharedHandle;
+ handle = new SharedHandle(key, address, message);
+ } else {
+ handle = new RoundRobinHandle(key, address, message);
}
- handle = new constructor(key, address, message);
handles.set(key, handle);
}