mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-12 00:43:03 +00:00
45 lines
1.9 KiB
C#
45 lines
1.9 KiB
C#
using CryptoExchange.Net.Objects;
|
|
|
|
namespace CryptoExchange.Net.RateLimiting.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// Rate limit guard
|
|
/// </summary>
|
|
public interface IRateLimitGuard
|
|
{
|
|
/// <summary>
|
|
/// Name
|
|
/// </summary>
|
|
string Name { get; }
|
|
|
|
/// <summary>
|
|
/// Description
|
|
/// </summary>
|
|
string Description { get; }
|
|
|
|
/// <summary>
|
|
/// Check whether a request can pass this rate limit guard
|
|
/// </summary>
|
|
/// <param name="type">The rate limit item type</param>
|
|
/// <param name="definition">The request definition</param>
|
|
/// <param name="host">The host address</param>
|
|
/// <param name="apiKey">The API key</param>
|
|
/// <param name="requestWeight">The request weight</param>
|
|
/// <param name="keySuffix">An additional optional suffix for the key selector. Can be used to make rate limiting work based on parameters.</param>
|
|
/// <returns></returns>
|
|
LimitCheck Check(RateLimitItemType type, RequestDefinition definition, string host, string? apiKey, int requestWeight, string? keySuffix);
|
|
|
|
/// <summary>
|
|
/// Apply the request to this guard with the specified weight
|
|
/// </summary>
|
|
/// <param name="type">The rate limit item type</param>
|
|
/// <param name="definition">The request definition</param>
|
|
/// <param name="host">The host address</param>
|
|
/// <param name="apiKey">The API key</param>
|
|
/// <param name="requestWeight">The request weight</param>
|
|
/// <param name="keySuffix">An additional optional suffix for the key selector. Can be used to make rate limiting work based on parameters.</param>
|
|
/// <returns></returns>
|
|
RateLimitState ApplyWeight(RateLimitItemType type, RequestDefinition definition, string host, string? apiKey, int requestWeight, string? keySuffix);
|
|
}
|
|
}
|