Class RateLimitManager
- Namespace
- Fluxer.Net.RateLimiting
- Assembly
- Fluxer.Net.dll
Manages rate limit buckets for API requests with sliding window algorithm
public class RateLimitManager
- Inheritance
-
objectRateLimitManager
Constructors
RateLimitManager(bool)
public RateLimitManager(bool enableRateLimiting = true)
Parameters
enableRateLimitingbool
Properties
ActiveBucketCount
Gets the total number of active buckets
public int ActiveBucketCount { get; }
Property Value
Methods
ClearAllBucketsAsync()
Clears all rate limit buckets (useful for testing)
public Task ClearAllBucketsAsync()
Returns
GetBucket(RateLimitConfig, ulong?, ulong?, ulong?, ulong?, string)
Gets or creates a rate limit bucket for the given configuration and dynamic parameters
public RateLimitBucket GetBucket(RateLimitConfig config, ulong? channelId = null, ulong? guildId = null, ulong? userId = null, ulong? webhookId = null, string inviteCode = null)
Parameters
configRateLimitConfigThe rate limit configuration
channelIdulong?Optional channel ID for channel-specific buckets
guildIdulong?Optional guild ID for guild-specific buckets
userIdulong?Optional user ID for user-specific buckets
webhookIdulong?Optional webhook ID for webhook-specific buckets
inviteCodestringOptional invite code for invite-specific buckets
Returns
- RateLimitBucket
The rate limit bucket
GetBucketInfoAsync(RateLimitBucket)
Gets information about a specific bucket
public Task<(int remaining, int resetMs)> GetBucketInfoAsync(RateLimitBucket bucket)
Parameters
bucketRateLimitBucket
Returns
WaitForRateLimitAsync(RateLimitBucket)
Waits for rate limit if necessary before proceeding with request
public Task WaitForRateLimitAsync(RateLimitBucket bucket)
Parameters
bucketRateLimitBucketThe rate limit bucket to check
Returns
- Task
Task that completes when request can proceed