new ClusterManager(file, optionsopt)
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file | string | Path to your bot file | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options | object | <optional> | Options for the cluster manager Properties
|
- Source
Members
clusterData :object
Data, which is passed to the workerData or the processEnv
- object
- Source
clusterList :Array.<number>
A Array of IDS[Number], which should be assigned to the spawned Clusters
- Array.<number>
- Source
clusterOptions :object
Options, which is passed when forking a child or creating a thread
- object
- Source
clusters :Collection.<number, Cluster>
A collection of all clusters the manager spawned
- Collection.<number, Cluster>
- Source
execArgv :Array.<string>
An array of arguments to pass to the executable (only when ClusterManager#mode is process
)
- Array.<string>
- Source
file :string
Path to the bot script file
- string
- Source
mode :ClusterManagerMode
Mode for shards to spawn with
- ClusterManagerMode
- Source
respawn :boolean
Whether clusters should automatically respawn upon exiting
- boolean
- Source
restarts :Object
How many times a cluster can maximally restart in the given interval
- Object
- Source
shardArgs :Array.<string>
An array of arguments to pass to clusters (only when ClusterManager#mode is process
)
- Array.<string>
- Source
shardList :string|Array.<number>
List of internal shard ids this cluster manager spawns
- string | Array.<number>
- Source
shardsPerClusters :number
Amount of Shards per Clusters
- number
- Source
(nullable) token :string
Token to use for obtaining the automatic internal shards count, and passing to bot script
- string
- Source
totalClusters :number
Amount of total clusters to spawn
- number
- Source
totalShards :number
Amount of internal shards in total
- number
- Source
Methods
_debug(message, cluster) → {string}
Logs out the Debug Messages
Name | Type | Description |
---|---|---|
message | ||
cluster |
- Source
returns the log message
- Type:
- string
broadcast(message) → {Promise.<Array.<Cluster>>}
Sends a message to all clusters.
Name | Type | Description |
---|---|---|
message | * | Message to be sent to the clusters |
- Source
- Type:
- Promise.<Array.<Cluster>>
broadcastEval(script, optionsopt) → {Promise.<*>|Promise.<Array.<*>>}
Evaluates a script on all clusters, or a given cluster, in the context of the Clients.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
script | string | function | JavaScript to run on each cluster | ||
options | Object | <optional> | {} | The options for the broadcastEVal |
- Source
Results of the script execution
- Type:
- Promise.<*> | Promise.<Array.<*>>
createCluster(id, shardsToSpawn, totalShards) → {CLUSTER}
Creates a single cluster.
Name | Type | Description |
---|---|---|
id | ||
shardsToSpawn | ||
totalShards |
- Source
Note that the created cluster needs to be explicitly spawned using its spawn method.
- Type:
- CLUSTER
extend()
Adds a plugin to the cluster manager
- Source
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.<*>>
manager.fetchClientValues('guilds.cache.size')
.then(results => console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`))
.catch(console.error);
(async) respawnAll(optionsopt) → {Promise.<Collection.<number, Cluster>>}
Kills all running clusters and respawns them.
Name | Type | Attributes | Description |
---|---|---|---|
options | ClusterRespawnOptions | <optional> | Options for respawning shards |
- Source
- Type:
- Promise.<Collection.<number, Cluster>>
triggerMaintenance(reason)
Name | Type | Description |
---|---|---|
reason | string | If maintenance should be enabled on all clusters with a given reason or disabled when nonce provided |
- Source
Events
clusterCreate
Emitted upon creating a cluster.
Name | Type | Description |
---|---|---|
cluster | Cluster | Cluster that was created |
- Source
debug
Emitted upon receiving a message
Name | Type | Description |
---|---|---|
Message, | string | which was received |
- Source