Skip to content

Commit

Permalink
cluster: clarify construct Handle
Browse files Browse the repository at this point in the history
Improve the readability for costruct SharedHandle and
RoundRobinHandle

PR-URL: #37385
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
JacksonTian authored and danielleadams committed Mar 16, 2021
1 parent 732d8ca commit 8e1257e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/internal/cluster/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,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)) ||
Expand Down Expand Up @@ -299,17 +298,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);
}

Expand Down

0 comments on commit 8e1257e

Please sign in to comment.