From 8e1257e26d6b50164f0093905a60aa7dde2618fc Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Mon, 15 Feb 2021 23:33:35 +0800 Subject: [PATCH] cluster: clarify construct Handle Improve the readability for costruct SharedHandle and RoundRobinHandle PR-URL: https://github.com/nodejs/node/pull/37385 Reviewed-By: Zijian Liu Reviewed-By: Darshan Sen Reviewed-By: James M Snell --- lib/internal/cluster/master.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index c52fd9577ac833..3ef22a5e280acc 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -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)) || @@ -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); }