public class BucketRateLimiter<T> extends Object implements RateLimiter<T>
Constructor and Description |
---|
BucketRateLimiter(long capacity,
long tokensGeneratedInPeriod,
Duration period) |
Modifier and Type | Method and Description |
---|---|
void |
forget(T item)
Forget indicates that an item is finished being retried.
|
int |
numRequeues(T item) |
Duration |
when(T item)
When gets an item and gets to decide how long that item should wait
|
public BucketRateLimiter(long capacity, long tokensGeneratedInPeriod, Duration period)
capacity
- Capacity is the maximum number of tokens can be consumed.tokensGeneratedInPeriod
- Tokens generated in period.period
- Period that generating specific number of tokens.public Duration when(T item)
RateLimiter
when
in interface RateLimiter<T>
item
- Item that should waitpublic void forget(T item)
RateLimiter
forget
in interface RateLimiter<T>
item
- Item will be forgetpublic int numRequeues(T item)
numRequeues
in interface RateLimiter<T>
Copyright © 2022. All rights reserved.