new ClusterClient(client)
Name | Type | Description |
---|---|---|
client | Client | Client of the current cluster |
- Source
Members
client :Client
Client for the Cluster
- Source
(readonly) count :number
Total number of clusters
- number
- Source
(readonly) id :number
cluster's id
- number
- Source
(readonly) ids :Map.<number, any>
Array of shard IDs of this client
- Map.<number, any>
- Source
(readonly) info :object
Gets several Info like Cluster_Count, Number, Total shards...
- object
- Source
maintenance :String
If the Cluster is under maintenance
- String
- Source
mode :ClusterManagerMode
Mode the Cluster was spawned with
- ClusterManagerMode
- Source
queue :Object
If the Cluster is spawned automatically or with a own controller
- Object
- Source
Methods
(static) getInfo() → {Object}
gets the total Internal shard count and shard list.
- Source
- Type:
- Object
(async) broadcastEval(script, options) → {Promise.<*>|Promise.<Array.<*>>}
Evaluates a script or function on all clusters, or a given cluster, in the context of the Clients.
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
script | string | function | JavaScript to run on each cluster | ||||||||||||||||||||||||||||||
options | object | Some options such as the TargetCluster or the Eval timeout Properties
|
- Source
Results of the script execution
- Type:
- Promise.<*> | Promise.<Array.<*>>
client.cluster.broadcastEval('this.guilds.cache.size')
.then(results => console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`))
.catch(console.error);
(async) evalOnManager(script, options) → {Promise.<*>|Promise.<Array.<*>>}
Evaluates a script or function on the Cluster Manager
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
script | string | function | JavaScript to run on the Manager | |||||||||||||||
options | object | Some options such as the Eval timeout or the Context Properties
|
- Source
- See
- ClusterManager#evalOnManager
Result of the script execution
- Type:
- Promise.<*> | Promise.<Array.<*>>
client.cluster.evalOnManager('process.uptime')
.then(result => console.log(result))
.catch(console.error);
fetchClientValues(prop, clusteropt) → {Promise.<*>|Promise.<Array.<*>>}
Fetches a client property value of each cluster, or a given cluster.
Name | Type | Attributes | Description |
---|---|---|---|
prop | string | Name of the client property to get, using periods for nesting | |
cluster | number | <optional> | Cluster to fetch property from, all if undefined |
- Source
- Type:
- Promise.<*> | Promise.<Array.<*>>
client.cluster.fetchClientValues('guilds.cache.size')
.then(results => console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`))
.catch(console.error);
request(message) → {Promise.<*>}
Sends a Request to the ParentCluster and returns the reply
Name | Type | Description |
---|---|---|
message | Object | Message, which should be sent as request |
- Source
Reply of the Message
- Type:
- Promise.<*>
client.cluster.request({content: 'hello'})
.then(result => console.log(result)) //hi
.catch(console.error);
respawnAll(optionsopt) → {Promise.<void>}
Requests a respawn of all clusters.
Name | Type | Attributes | Description |
---|---|---|---|
options | ClusterRespawnOptions | <optional> | Options for respawning shards |
- Source
Resolves upon the message being sent
- Type:
- Promise.<void>
send(message) → {Promise.<void>}
Sends a message to the master process.
Name | Type | Description |
---|---|---|
message | * | Message to send |
- Source
- Cluster#event:message
- Type:
- Promise.<void>
spawnNextCluster() → {Promise.<*>}
Manually spawn the next cluster, when queue mode is on 'manual'
- Source
- Type:
- Promise.<*>
triggerMaintenance(maintenance, all) → {String}
Name | Type | Default | Description |
---|---|---|---|
maintenance | String | Whether the cluster should opt in maintenance when a reason was provided or opt-out when no reason was provided. | |
all | Boolean | false | Whether to target it on all clusters or just the current one. |
- Source
The maintenance status of the cluster.
- Type:
- String
Events
message
Emitted upon receiving a message from the parent process/worker.
Name | Type | Description |
---|---|---|
message | * | Message that was received |
- Source