TokenBucketLimiter
class TokenBucketLimiter(val capacity: Long, val refillTokenInterval: Duration, clock: Clock, stateStorage: StateStorage = MemoryStateStorage()) : RateLimiter
A token bucket rate limiter implementation.
Parameters
capacity
the maximum number of tokens that can be stored in the bucket
refillTokenInterval
the interval at which tokens are added to the bucket
clock
the clock to use to get the current time
stateStorage
the state storage to use to store the bucket state
Constructors
Link copied to clipboard
constructor(capacity: Long, refillTokenInterval: Duration, clock: Clock, stateStorage: StateStorage = MemoryStateStorage())
Functions
Link copied to clipboard
Wait until a token is available.
Wait until a token for the given key is available.