mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 08:26:20 +00:00
Fix for intermittently failing rate limiting test Added ConnectionId to RequestDefinition to correctly handle connection and path rate limiting configuration Added ValidateMessage method to websocket Query object to filter messages even though it is matched to the query based on the ListenIdentifier Added KlineTracker and TradeTracker implementation
89 lines
2.4 KiB
C#
89 lines
2.4 KiB
C#
using CryptoExchange.Net.RateLimiting.Interfaces;
|
|
using System.Net.Http;
|
|
|
|
namespace CryptoExchange.Net.Objects
|
|
{
|
|
/// <summary>
|
|
/// The definition of a rest request
|
|
/// </summary>
|
|
public class RequestDefinition
|
|
{
|
|
private string? _stringRep;
|
|
|
|
// Basics
|
|
|
|
/// <summary>
|
|
/// Path of the request
|
|
/// </summary>
|
|
public string Path { get; set; }
|
|
/// <summary>
|
|
/// Http method of the request
|
|
/// </summary>
|
|
public HttpMethod Method { get; set; }
|
|
/// <summary>
|
|
/// Is the request authenticated
|
|
/// </summary>
|
|
public bool Authenticated { get; set; }
|
|
|
|
|
|
// Formating
|
|
|
|
/// <summary>
|
|
/// The body format for this request
|
|
/// </summary>
|
|
public RequestBodyFormat? RequestBodyFormat { get; set; }
|
|
/// <summary>
|
|
/// The position of parameters for this request
|
|
/// </summary>
|
|
public HttpMethodParameterPosition? ParameterPosition { get; set; }
|
|
/// <summary>
|
|
/// The array serialization type for this request
|
|
/// </summary>
|
|
public ArrayParametersSerialization? ArraySerialization { get; set; }
|
|
|
|
// Rate limiting
|
|
|
|
/// <summary>
|
|
/// Request weight
|
|
/// </summary>
|
|
public int Weight { get; set; } = 1;
|
|
|
|
/// <summary>
|
|
/// Rate limit gate to use
|
|
/// </summary>
|
|
public IRateLimitGate? RateLimitGate { get; set; }
|
|
|
|
/// <summary>
|
|
/// Individual endpoint rate limit guard to use
|
|
/// </summary>
|
|
public IRateLimitGuard? LimitGuard { get; set; }
|
|
|
|
/// <summary>
|
|
/// Whether this request should never be cached
|
|
/// </summary>
|
|
public bool PreventCaching { get; set; }
|
|
|
|
/// <summary>
|
|
/// Connection id
|
|
/// </summary>
|
|
public int? ConnectionId { get; set; }
|
|
|
|
/// <summary>
|
|
/// ctor
|
|
/// </summary>
|
|
/// <param name="path"></param>
|
|
/// <param name="method"></param>
|
|
public RequestDefinition(string path, HttpMethod method)
|
|
{
|
|
Path = path;
|
|
Method = method;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString()
|
|
{
|
|
return _stringRep ??= $"{Method} {Path}{(Authenticated ? " authenticated" : "")}";
|
|
}
|
|
}
|
|
}
|