mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
Add config option for max shard concurrency
This commit is contained in:
parent
2039a34c16
commit
13e3289c26
4 changed files with 27 additions and 11 deletions
|
|
@ -2,7 +2,6 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Myriad.Types;
|
||||
|
|
@ -69,9 +68,10 @@ namespace Myriad.Gateway
|
|||
|
||||
await StartShards(concurrency);
|
||||
}
|
||||
|
||||
private async Task StartShards(int concurrency)
|
||||
{
|
||||
concurrency = GetActualShardConcurrency(concurrency);
|
||||
|
||||
var lastTime = DateTimeOffset.UtcNow;
|
||||
var identifyCalls = 0;
|
||||
|
||||
|
|
@ -112,5 +112,13 @@ namespace Myriad.Gateway
|
|||
if (EventReceived != null)
|
||||
await EventReceived(shard, evt);
|
||||
}
|
||||
|
||||
private int GetActualShardConcurrency(int recommendedConcurrency)
|
||||
{
|
||||
if (_gatewaySettings.MaxShardConcurrency == null)
|
||||
return recommendedConcurrency;
|
||||
|
||||
return Math.Min(_gatewaySettings.MaxShardConcurrency.Value, recommendedConcurrency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,5 +4,6 @@
|
|||
{
|
||||
public string Token { get; init; }
|
||||
public GatewayIntent Intents { get; init; }
|
||||
public int? MaxShardConcurrency { get; init; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue