RateLimitingAlgorithm
Represents all possible rate limiting algorithms that can be used to determine the behaviour of a RateLimiter.
See also
Inheritors
Types
Represents a rate limiting algorithm that will allow a fixed number of permits in a given time period (e.g., 5 requests per minute). At the beginning of each time window, the counter is reset, and requests are counted from that point.
Represents a rate limiting algorithm that divides the total time period into smaller segments or windows. Each segment has its own counter, and the rate limiter keeps track of the number of requests in each segment to provide a more accurate and smoother rate limiting mechanism. After segments * replenishmentPeriod, which emcompasses a window cycle, the oldest segment is removed, and a new segment is added. At any point, when a request arrives, the total number of requests in all segments is compared to the totalPermits limit.
Represents a rate limiting algorithm that has a fixed bucket size and refills the bucket with tokens at a constant rate. At each replenishmentPeriod, the bucket is refilled with 1 token (e.g., plus 1 token per second), never exceeding the totalPermits limit.
Properties
The maximum number of requests that can be queued when the rate limiter is exceeded. If set to 0, the rate limiter will reject requests immediately when the limit is reached.
The amount of time that must pass before the rate limiting algorithm replenishes permits. Depends on the algorithm.
The total number of permits that can be allowed in a given replenishmentPeriod.