detritus

ClusterManagerclass

Spawns and supervises child processes, each running a ClusterClient over a range of shards.

On this page
import { ClusterManager } from 'detritus-client';
EventEmitterEventSpewerClusterManager
15 properties9 methodssrc/clustermanager.ts:41

Constructor

Properties

_respawningAll
Promise<void> | null
Default null
_running
Promise<ClusterManager> | null
Default null
buckets
BaseCollection<number, Bucket>
execArgv?
string[]
optional
file
string
maxConcurrency
number
Default 1
processes
BaseCollection<number, ClusterProcess>
ran
boolean
Default false
respawn
boolean
Default true
rest
restCache
shardCount
number
Default 0
shardEnd
number
Default -1
shardsPerCluster
number
Default 4
shardStart
number
Default 0
token
string

Accessors

clusterCount
number
get

Methods

broadcastEval()

async src/clustermanager.ts:214
broadcastEval(code: string | Function, nonce?: string, timeout?: number): Promise<any[]>
code
string | Function
nonce?
string
timeout?
number
Default BROADCAST_EVAL_TIMEOUT

broadcastEvalRaw()

async src/clustermanager.ts:202
broadcastEvalRaw(
  code: string | Function,
  nonce?: string,
  timeout?: number,
): Promise<[any, boolean][]>
code
string | Function
nonce?
string
timeout?
number
Default BROADCAST_EVAL_TIMEOUT

on()

src/clustermanager.ts:261
on(event: string | symbol, listener: (...args: any[]) => void): this

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

server.on('connection', (stream) => {
  console.log('someone connected!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
//   b
//   a

Since v0.1.101

event
string | symbol
listener
(...args: any[]) => void

The callback function

on(
  event: CLUSTER_PROCESS,
  listener: (payload: { clusterProcess: ClusterProcess }) => any,
): this
on(
  event: "clusterProcess",
  listener: (payload: { clusterProcess: ClusterProcess }) => any,
): this
Overrides EventSpewer.on

once()

src/clustermanager.ts:269
once(event: string | symbol, listener: (...args: any[]) => void): this

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

server.once('connection', (stream) => {
  console.log('Ah, we have our first user!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.once('foo', () => console.log('a'));
myEE.prependOnceListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
//   b
//   a

Since v0.3.0

event
string | symbol
listener
(...args: any[]) => void

The callback function

once(
  event: CLUSTER_PROCESS,
  listener: (payload: { clusterProcess: ClusterProcess }) => any,
): this
once(
  event: "clusterProcess",
  listener: (payload: { clusterProcess: ClusterProcess }) => any,
): this
Overrides EventSpewer.once