From 0e2e8a9265a936945a8ed157915e7849e2ac500c 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 --- lib/internal/cluster/primary.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/internal/cluster/primary.js b/lib/internal/cluster/primary.js index e8113411790a11..49011369eee9ef 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); }