RateLimiter class
Rate limiter utility for controlling action frequency
Constructors
- RateLimiter.new({required int maxCalls, required Duration window})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxCalls → int
-
final
- remainingCalls → int
-
Get the number of remaining calls allowed
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timeUntilNextCall → Duration?
-
Get the time until the next call is allowed
no setter
- window → Duration
-
final
Methods
-
canExecute(
) → bool - Check if an action can be executed
-
dispose(
) → void - Dispose of the rate limiter
-
execute(
void action()) → bool - Execute the action if within rate limit
-
executeAsync(
Future< void> action()) → Future<bool> - Execute the action asynchronously if within rate limit
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Reset the rate limiter
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited