Class RateLimitBucket
- Namespace
- Fluxer.Net.RateLimiting
- Assembly
- Fluxer.Net.dll
Represents a sliding window rate limit bucket for API requests
public class RateLimitBucket
- Inheritance
-
objectRateLimitBucket
Constructors
RateLimitBucket(string, int, int, bool)
public RateLimitBucket(string bucketKey, int limit, int windowMs, bool exemptFromGlobal = false)
Parameters
Properties
BucketKey
public string BucketKey { get; }
Property Value
ExemptFromGlobal
public bool ExemptFromGlobal { get; }
Property Value
Limit
public int Limit { get; }
Property Value
WindowMs
public int WindowMs { get; }
Property Value
Methods
AcquireAsync()
Attempts to acquire a rate limit slot, waiting if necessary
public Task<int> AcquireAsync()
Returns
GetRemainingAsync()
Gets the number of available requests in the current window
public Task<int> GetRemainingAsync()
Returns
GetResetTimeAsync()
Gets the time in milliseconds until the next slot becomes available
public Task<int> GetResetTimeAsync()
Returns
ResetAsync()
Clears all tracked timestamps (useful for testing or manual reset)
public Task ResetAsync()