Skip to main content

Util

Hub containing some useful utils for other clusters.

Constructor​

new Util(cid);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
cidnumber❌undefinedCluster ID.

Methods​

getStats​

Requests stats from all clusters and returns an array.

getStats();

Returns​

Promise< ClusterStats[] >


getStatsFrom​

Returns stats on a specfic cluster and the shards it contains etc.

getStatsFrom(clusterId);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
clusterIdnumber❌nullCluster identifier.

Returns​

Promise< ClusterStats | undefined >


broadcastEval​

Sends callback as a string to every cluster then uses eval to evaulate your code on that cluster. It will return an array of objects which will contain cluster info and the result/error that occured.

broadcastEval(callback, references);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
callbackBroadcastEvalCallback❌undefinedCallback function to be evaulated.
referencesobject?✔️undefinedCallback function to be evaulated.

Returns​

Promise< BroadcastEvalResponse[] >


disposeOf​

Sends a request to specified cluster to dispose itself. Will result in the cluster exiting with code 0 and being automatically restarted by ClusterUtil.

disposeOf(clusterId);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
clusterIdnumber❌nullCluster identifier.

Returns​

void