mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Rewrite sharding class descriptions and link Client
This commit is contained in:
@@ -6,7 +6,8 @@ const { Error } = require('../errors');
|
||||
const delayFor = require('util').promisify(setTimeout);
|
||||
|
||||
/**
|
||||
* Represents a Shard spawned by the ShardingManager.
|
||||
* A self-contained shard spawned by the {@link ShardingManager}.
|
||||
* @extends EventEmitter
|
||||
*/
|
||||
class Shard extends EventEmitter {
|
||||
/**
|
||||
@@ -171,7 +172,7 @@ class Shard extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates a script on the shard, in the context of the client.
|
||||
* Evaluates a script on the shard, in the context of the {@link Client}.
|
||||
* @param {string} script JavaScript to run on the shard
|
||||
* @returns {Promise<*>} Result of the script execution
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,8 @@ const { Events } = require('../util/Constants');
|
||||
const { Error } = require('../errors');
|
||||
|
||||
/**
|
||||
* Helper class for sharded clients spawned as a child process, such as from a ShardingManager.
|
||||
* Helper class for sharded clients spawned as a child process, such as from a {@link ShardingManager}.
|
||||
* Utilises IPC to send and receive data to/from the master process and other shards.
|
||||
*/
|
||||
class ShardClientUtil {
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ class ShardClientUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates a script on all shards, in the context of the Clients.
|
||||
* Evaluates a script on all shards, in the context of the {@link Clients}.
|
||||
* @param {string} script JavaScript to run on each shard
|
||||
* @returns {Promise<Array<*>>} Results of the script execution
|
||||
* @see {@link ShardingManager#broadcastEval}
|
||||
|
||||
@@ -8,9 +8,12 @@ const { Error, TypeError, RangeError } = require('../errors');
|
||||
const delayFor = require('util').promisify(setTimeout);
|
||||
|
||||
/**
|
||||
* This is a utility class that can be used to help you spawn shards of your client. Each shard is completely separate
|
||||
* from the other. The Shard Manager takes a path to a file and spawns it under the specified amount of shards safely.
|
||||
* If you do not select an amount of shards, the manager will automatically decide the best amount.
|
||||
* This is a utility class that makes multi-process sharding of a bot an easy and painless experience.
|
||||
* It works by spawning a self-contained {@link ChildProcess} for each individual shard, each containing its own client.
|
||||
* They all have a line of communication with the master process, and there are several useful methods that utilise
|
||||
* it in order to simplify tasks that are normally difficult with multi-process sharding. It can spawn a specific number
|
||||
* of shards or the amount that Discord suggests for the bot, and takes a path to your main bot script to launch for
|
||||
* each one.
|
||||
* @extends {EventEmitter}
|
||||
*/
|
||||
class ShardingManager extends EventEmitter {
|
||||
@@ -148,7 +151,7 @@ class ShardingManager extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates a script on all shards, in the context of the Clients.
|
||||
* Evaluates a script on all shards, in the context of the {@link Client}s.
|
||||
* @param {string} script JavaScript to run on each shard
|
||||
* @returns {Promise<Array<*>>} Results of the script execution
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user