RateLimiter class
A sliding-window rate limiter utility.
Constructors
- RateLimiter({required int maxRequests, required Duration duration})
-
Creates a RateLimiter allowing up to
maxRequestsexecutions perduration.
Properties
- canRun → bool
-
Whether execution is allowed under the current rate limit.
no setter
- duration → Duration
-
Time window duration for rate limiting.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxRequests → int
-
Maximum number of allowed executions within duration.
final
- remainingRequests → int
-
Number of remaining executions allowed in the current window.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Resets the rate limiter history.
-
toString(
) → String -
A string representation of this object.
inherited
-
tryRun(
void action()) → bool -
Attempts to run
action. Returnstrueif executed,falseif rate-limited.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited