1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-23 06:13:09 +00:00

Added Reset functionality to rate limiter implementation, added reset of rate limit per connection when connection is disconnected

This commit is contained in:
Jkorf
2026-04-10 09:39:19 +02:00
parent 93d92beea6
commit 9add5e0adc
14 changed files with 416 additions and 231 deletions
@@ -88,5 +88,15 @@ namespace CryptoExchange.Net.RateLimiting.Guards
: _windowType == RateLimitWindowType.Fixed ? new FixedWindowTracker(_limit, _period) :
new DecayWindowTracker(_limit, _period, _decayRate ?? throw new InvalidOperationException("Decay rate not provided"));
}
/// <inheritdoc />
public void Reset(RateLimitItemType type, RequestDefinition definition, string host, string? apiKey, string? keySuffix)
{
var key = _keySelector(definition, host, apiKey) + keySuffix;
if (!_trackers.TryGetValue(key, out var tracker))
return;
tracker.Reset();
}
}
}