TokenBucket class

Classic token bucket. Allows bursts up to capacity, refilled at refillPerSecond tokens per second.

Inheritance

Constructors

TokenBucket({required double capacity, required double refillPerSecond, DateTime now()?})
Build a token bucket.

Properties

capacity → double
Maximum tokens the bucket can hold.
final
hashCode → int
The hash code for this object.
no setterinherited
refillPerSecond → double
Tokens added per second.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

acquire() → Future<void>
Wait until a token is available, then consume it.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
snapshot() → RateLimiterSnapshot
Observability snapshot.
override
toString() → String
A string representation of this object.
inherited
tryAcquire() → bool
Try to consume a token without blocking. Returns false when the limiter is empty.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited