MCPcopy Index your code
hub / github.com/nodejs/node / RoundRobinHandle

Function RoundRobinHandle

lib/internal/cluster/round_robin_handle.js:17–48  ·  view source on GitHub ↗
(key, address, { port, fd, flags, backlog, readableAll, writableAll })

Source from the content-addressed store, hash-verified

15module.exports = RoundRobinHandle;
16
17function RoundRobinHandle(key, address, { port, fd, flags, backlog, readableAll, writableAll }) {
18 this.key = key;
19 this.all = new SafeMap();
20 this.free = new SafeMap();
21 this.handles = init({ __proto__: null });
22 this.handle = null;
23 this.server = net.createServer(assert.fail);
24
25 if (fd >= 0)
26 this.server.listen({ fd, backlog });
27 else if (port >= 0) {
28 this.server.listen({
29 port,
30 host: address,
31 // Currently, net module only supports `ipv6Only` option in `flags`.
32 ipv6Only: Boolean(flags & constants.UV_TCP_IPV6ONLY),
33 backlog,
34 });
35 } else
36 this.server.listen({
37 path: address,
38 backlog,
39 readableAll,
40 writableAll,
41 }); // UNIX socket path.
42 this.server.once('listening', () => {
43 this.handle = this.server._handle;
44 this.handle.onconnection = (err, handle) => this.distribute(err, handle);
45 this.server._handle = null;
46 this.server = null;
47 });
48}
49
50RoundRobinHandle.prototype.add = function(worker, send) {
51 assert(this.all.has(worker.id) === false);

Callers

nothing calls this directly

Calls 3

listenMethod · 0.80
initFunction · 0.50
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…