Rewrite sharding class descriptions and link Client

This commit is contained in:
Schuyler Cebulskie
2017-11-19 02:21:29 -05:00
parent 9cd097492c
commit 975da5f1a5
3 changed files with 13 additions and 8 deletions

View File

@@ -6,7 +6,8 @@ const { Error } = require('../errors');
const delayFor = require('util').promisify(setTimeout); 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 { 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 * @param {string} script JavaScript to run on the shard
* @returns {Promise<*>} Result of the script execution * @returns {Promise<*>} Result of the script execution
*/ */

View File

@@ -3,7 +3,8 @@ const { Events } = require('../util/Constants');
const { Error } = require('../errors'); 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 { 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 * @param {string} script JavaScript to run on each shard
* @returns {Promise<Array<*>>} Results of the script execution * @returns {Promise<Array<*>>} Results of the script execution
* @see {@link ShardingManager#broadcastEval} * @see {@link ShardingManager#broadcastEval}

View File

@@ -8,9 +8,12 @@ const { Error, TypeError, RangeError } = require('../errors');
const delayFor = require('util').promisify(setTimeout); 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 * This is a utility class that makes multi-process sharding of a bot an easy and painless experience.
* from the other. The Shard Manager takes a path to a file and spawns it under the specified amount of shards safely. * It works by spawning a self-contained {@link ChildProcess} for each individual shard, each containing its own client.
* If you do not select an amount of shards, the manager will automatically decide the best amount. * 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} * @extends {EventEmitter}
*/ */
class ShardingManager 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 * @param {string} script JavaScript to run on each shard
* @returns {Promise<Array<*>>} Results of the script execution * @returns {Promise<Array<*>>} Results of the script execution
*/ */