IShardingManager.create constructor

IShardingManager.create(
  1. ProcessData processData, {
  2. int? shardsPerProcess,
  3. int? numProcesses,
  4. int? totalShards,
  5. int? maxGuildsPerShard,
  6. int? maxGuildsPerProcess,
  7. String? token,
  8. ShardingOptions options = const ShardingOptions(),
})

Create a new IShardingManager.

The table below indicates how the different combinations of values are combined to calculate process counts and shard counts:

sPP = shardsPerProcess
nP = numProcesses
tS = totalShards
gPS = guildsPerShard
gPP = guildsPerProcess
tkn = token
gC = guildCount

fetch(d) = fetch `d` from the Discord API using the provided token

|t|s|n|t|g|g|
|k|P|P|S|P|P|
|n|P| | |S|P|
|-|-|-|-|-|-|
|x|x|x|x|x|x| CHECK tS = nP * sPP; WARN IF fetch(gC) / nP > gPP; WARN IF fetch(gC) / tS > gPS;
|x|x|x|x|x| | CHECK tS = nP * sPP; WARN IF fetch(gC) / tS > gPS;
|x|x|x|x| |x| CHECK tS = nP * sPP; WARN IF fetch(gC) / nP > gPP;
|x|x|x|x| | | CHECK tS = nP * sPP;
|x|x|x| |x|x| USE tS = sPP * nP; WARN IF fetch(gC) / nP > gPP; WARN IF fetch(gC) / tS > gPS;
|x|x|x| |x| | USE tS = sPP * nP; WARN IF fetch(gC) / tS > gPS;
|x|x|x| | |x| USE tS = sPP * nP; WARN IF fetch(gC) / nP > gPP;
|x|x|x| | | | USE tS = sPP * nP;
|x|x| |x|x|x| USE nP = ceil(tS / sPP); WARN IF fetch(gC) / nP > gPP; WARN IF fetch(gC) / tS > gPS;
|x|x| |x|x| | USE nP = ceil(tS / sPP); WARN IF fetch(gC) / tS > gPS;
|x|x| |x| |x| USE nP = ceil(tS / sPP); WARN IF fetch(gC) / nP > gPP;
|x|x| |x| | | USE nP = ceil(tS / sPP);
|x|x| | |x|x| USE tS = ceil(fetch(gC) / gPS); USE nP = ceil(tS / sPP); WARN IF fetch(gC) / nP > gPP;
|x|x| | |x| | USE tS = ceil(fetch(gC) / gPS); USE nP = ceil(tS / sPP);
|x|x| | | |x| USE nP = ceil(fetch(gC) / gPP); USE tS = sPP * nP;
|x|x| | | | | USE tS = fetch(tS); USE nP = ceil(tS / sPP);
|x| |x|x|x|x| USE sPP = ceil(tS / nP); WARN IF fetch(gC) / nP > gPP; WARN IF fetch(gC) / tS > gPS;
|x| |x|x|x| | USE sPP = ceil(tS / nP); WARN IF fetch(gC) / tS > gPS;
|x| |x|x| |x| USE sPP = ceil(tS / nP); WARN IF fetch(gC) / nP > gPP;
|x| |x|x| | | USE sPP = ceil(tS / nP);
|x| |x| |x|x| USE tS = ceil(fetch(gC) / gPS); USE sPP = ceil(tS / nP); WARN IF fetch(gC) / nP > gPP;
|x| |x| |x| | USE tS = ceil(fetch(gC) / gPS); USE sPP = ceil(tS / nP);
|x| |x| | |x| USE tS = fetch(tS); USE sPP = ceil(tS / nP); WARN IF fetch(gC) / nP > gPP;
|x| |x| | | | USE tS = fetch(tS); USE sPP = ceil(tS / nP);
|x| | |x|x|x| USE nP = ceil(fetch(gC) / gPP); USE sPP = ceil(tS / nP); WARN IF fetch(gC) / tS > gPS;
|x| | |x|x| | ERROR
|x| | |x| |x| USE nP = ceil(fetch(gC) / gPP); USE sPP = ceil(tS / nP);
|x| | |x| | | ERROR
|x| | | |x|x| USE nP = ceil(fetch(gC) / gPP); USE tS = ceil(fetch(gC) / gPS); USE sPP = ceil(tS / nP);
|x| | | |x| | ERROR
|x| | | | |x| USE nP = ceil(fetch(gC) / gPP); USE tS = fetch(tS); USE sPP = ceil(tS / nP);
|x| | | | | | ERROR
| |x|x|x|x|x| CHECK tS = nP * sPP; WARN "No token to fetch guild count";
| |x|x|x|x| | CHECK tS = nP * sPP; WARN "No token to fetch guild count";
| |x|x|x| |x| CHECK tS = nP * sPP; WARN "No token to fetch guild count";
| |x|x|x| | | CHECK tS = nP * sPP;
| |x|x| |x|x| USE tS = sPP * nP; WARN "No token to fetch guild count";
| |x|x| |x| | USE tS = sPP * nP; WARN "No token to fetch guild count";
| |x|x| | |x| USE tS = sPP * nP; WARN "No token to fetch guild count";
| |x|x| | | | USE tS = sPP * nP;
| |x| |x|x|x| USE nP = ceil(tS / sPP); WARN "No token to fetch guild count";
| |x| |x|x| | USE nP = ceil(tS / sPP); WARN "No token to fetch guild count";
| |x| |x| |x| USE nP = ceil(tS / sPP); WARN "No token to fetch guild count";
| |x| |x| | | USE nP = ceil(tS / sPP);
| |x| | |x|x| ERROR
| |x| | |x| | ERROR
| |x| | | |x| ERROR
| |x| | | | | ERROR
| | |x|x|x|x| USE sPP = ceil(tS / nP); WARN "No token to fetch guild count";
| | |x|x|x| | USE sPP = ceil(tS / nP); WARN "No token to fetch guild count";
| | |x|x| |x| USE sPP = ceil(tS / nP); WARN "No token to fetch guild count";
| | |x|x| | | USE sPP = ceil(tS / nP);
| | |x| |x|x| ERROR
| | |x| |x| | ERROR
| | |x| | |x| ERROR
| | |x| | | | ERROR
| | | |x|x|x| ERROR
| | | |x|x| | ERROR
| | | |x| |x| ERROR
| | | |x| | | ERROR
| | | | |x|x| ERROR
| | | | |x| | ERROR
| | | | | |x| ERROR
| | | | | | | ERROR

Implementation

factory IShardingManager.create(
  ProcessData processData, {
  int? shardsPerProcess,
  int? numProcesses,
  int? totalShards,
  int? maxGuildsPerShard,
  int? maxGuildsPerProcess,
  String? token,
  ShardingOptions options = const ShardingOptions(),
}) =>
    ShardingManager(
      processData,
      shardsPerProcess: shardsPerProcess,
      numProcesses: numProcesses,
      totalShards: totalShards,
      maxGuildsPerProcess: maxGuildsPerProcess,
      maxGuildsPerShard: maxGuildsPerShard,
      token: token,
      options: options,
    );