RateLimiter class
A rate limiter that enforces rate limits for different domains
Constructors
- RateLimiter.new({int defaultRequestsPerMinute = 30, int defaultRequestsPerHour = 500, int defaultRequestsPerDay = 5000, Logger? logger})
- Creates a new RateLimiter
Properties
- defaultRequestsPerDay → int
-
The default requests per day
final
- defaultRequestsPerHour → int
-
The default requests per hour
final
- defaultRequestsPerMinute → int
-
The default requests per minute
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger → Logger?
-
Logger for logging rate limiting operations
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → void - Clears all rate limiting data
-
getCurrentRequestCountPerDay(
String domain) → int - Gets the current request count for the given domain (per day)
-
getCurrentRequestCountPerHour(
String domain) → int - Gets the current request count for the given domain (per hour)
-
getCurrentRequestCountPerMinute(
String domain) → int - Gets the current request count for the given domain (per minute)
-
getPendingRequestCount(
String domain) → int - Gets the number of pending requests for the given domain
-
getRateLimitPerDay(
String domain) → int - Gets the rate limit for a specific domain (requests per day)
-
getRateLimitPerHour(
String domain) → int - Gets the rate limit for a specific domain (requests per hour)
-
getRateLimitPerMinute(
String domain) → int - Gets the rate limit for a specific domain (requests per minute)
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setDomainLimit(
String domain, {int? requestsPerMinute, int? requestsPerHour, int? requestsPerDay}) → void - Sets the rate limit for a specific domain
-
toString(
) → String -
A string representation of this object.
inherited
-
waitForPermission(
String domain) → Future< void> - Waits until a request can be made to the given domain
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited