mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-16 10:40:12 +00:00
Add basic support for multi-node clustering
This commit is contained in:
parent
b09a34d9cd
commit
d61f61fead
3 changed files with 53 additions and 10 deletions
|
|
@ -32,17 +32,19 @@ namespace Myriad.Gateway
|
|||
|
||||
public async Task Start(GatewayInfo.Bot info)
|
||||
{
|
||||
var concurrency = GetActualShardConcurrency(info.SessionStartLimit.MaxConcurrency);
|
||||
_ratelimiter = new(_logger, concurrency);
|
||||
|
||||
await Start(info.Url, info.Shards);
|
||||
await Start(info.Url, 0, info.Shards - 1, info.Shards, info.SessionStartLimit.MaxConcurrency);
|
||||
}
|
||||
|
||||
public async Task Start(string url, int shardCount)
|
||||
public async Task Start(string url, int shardMin, int shardMax, int shardTotal, int concurrency)
|
||||
{
|
||||
_logger.Information("Starting {ShardCount} shards at {Url}", shardCount, url);
|
||||
for (var i = 0; i < shardCount; i++)
|
||||
CreateAndAddShard(url, new ShardInfo(i, shardCount));
|
||||
concurrency = GetActualShardConcurrency(concurrency);
|
||||
_ratelimiter = new(_logger, concurrency);
|
||||
|
||||
var shardCount = shardMax - shardMin + 1;
|
||||
_logger.Information("Starting {ShardCount} of {ShardTotal} shards (#{ShardMin}-#{ShardMax}) at {Url}",
|
||||
shardCount, shardTotal, shardMin, shardMax, url);
|
||||
for (var i = shardMin; i <= shardMax; i++)
|
||||
CreateAndAddShard(url, new ShardInfo(i, shardTotal));
|
||||
|
||||
await StartShards();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue