RateLimiter<T> class
A rate limiter utility for controlling the frequency of operations
This implementation follows the token bucket pattern where:
- Events are allowed up to bucketSize before rate limiting kicks in
- Once rate limited, events are processed at intervals
- The bucket resets after a period of inactivity
Security features:
- Maximum queue size to prevent memory exhaustion
- Timer validation to prevent DoS attacks
- Automatic disposal of resources
Constructors
- RateLimiter(dynamic _originalFunction(T), RateLimitConfig _config)
Properties
- executionCount → int
-
Get current execution count (for testing/debugging)
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Get disposal status (for testing/debugging)
no setter
- isRateLimited → bool
-
Get rate limit status (for testing/debugging)
no setter
- queueLength → int
-
Get current queue length (for testing/debugging)
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
T argument) → Future< void> - Execute the rate-limited function
-
dispose(
) → void - Dispose resources and cancel timers
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- maxQueueSize → const int
- maxTimerDuration → const int