Skip to content

Commit 1fac05e

Browse files
committed
cluster: restructure to same prototype for cluster child
Since `rr` and `shared` both belongs to the same prototype declaration and differes only in the handler declaration, this can be abstracted to a same type of function arguments passing.
1 parent f392ac0 commit 1fac05e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/internal/cluster/child.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ cluster._getServer = function(obj, options, cb) {
102102
obj._setServerData(reply.data);
103103

104104
if (handle)
105-
shared(reply, handle, indexesKey, index, cb); // Shared listen socket.
105+
shared(reply, { handle, indexesKey, index }, cb); // Shared listen socket.
106106
else
107-
rr(reply, indexesKey, index, cb); // Round-robin.
107+
rr(reply, { indexesKey, index }, cb); // Round-robin.
108108
});
109109

110110
obj.once('listening', () => {
@@ -129,7 +129,7 @@ function removeIndexesKey(indexesKey, index) {
129129
}
130130

131131
// Shared listen socket.
132-
function shared(message, handle, indexesKey, index, cb) {
132+
function shared(message, { handle, indexesKey, index }, cb) {
133133
const key = message.key;
134134
// Monkey-patch the close() method so we can keep track of when it's
135135
// closed. Avoids resource leaks when the handle is short-lived.
@@ -146,8 +146,8 @@ function shared(message, handle, indexesKey, index, cb) {
146146
cb(message.errno, handle);
147147
}
148148

149-
// Round-robin. Primary distributes handles across workers.
150-
function rr(message, indexesKey, index, cb) {
149+
// Round-robin. Master distributes handles across workers.
150+
function rr(message, { indexesKey, index }, cb) {
151151
if (message.errno)
152152
return cb(message.errno, null);
153153

0 commit comments

Comments
 (0)