Skip to content

Commit 8e1257e

Browse files
JacksonTiandanielleadams
authored andcommitted
cluster: clarify construct Handle
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>
1 parent 732d8ca commit 8e1257e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/internal/cluster/master.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ function createWorkerProcess(id, env) {
114114
const workerEnv = { ...process.env, ...env, NODE_UNIQUE_ID: `${id}` };
115115
const execArgv = [...cluster.settings.execArgv];
116116
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
117-
const nodeOptions = process.env.NODE_OPTIONS ?
118-
process.env.NODE_OPTIONS : '';
117+
const nodeOptions = process.env.NODE_OPTIONS || '';
119118

120119
if (ArrayPrototypeSome(execArgv,
121120
(arg) => RegExpPrototypeTest(debugArgRegex, arg)) ||
@@ -299,17 +298,17 @@ function queryServer(worker, message) {
299298
address = message.address;
300299
}
301300

302-
let constructor = RoundRobinHandle;
303301
// UDP is exempt from round-robin connection balancing for what should
304302
// be obvious reasons: it's connectionless. There is nothing to send to
305303
// the workers except raw datagrams and that's pointless.
306304
if (schedulingPolicy !== SCHED_RR ||
307305
message.addressType === 'udp4' ||
308306
message.addressType === 'udp6') {
309-
constructor = SharedHandle;
307+
handle = new SharedHandle(key, address, message);
308+
} else {
309+
handle = new RoundRobinHandle(key, address, message);
310310
}
311311

312-
handle = new constructor(key, address, message);
313312
handles.set(key, handle);
314313
}
315314

0 commit comments

Comments
 (0)