public class Throttler extends Object
| Constructor and Description |
|---|
Throttler(String name,
double maxRatePerSecond,
long rateIntervalMilliseconds)
Construct throttler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
setMaxRatePerSecond(double maxRatePerSecond) |
void |
throttle()
When called on each request sleeps if called faster then configured average rate.
|
void |
throttle(int count) |
public Throttler(String name, double maxRatePerSecond, long rateIntervalMilliseconds)
name - Human readable name of the resource being throttled. Used for logging only.maxRatePerSecond - maximum rate allowedrateIntervalMilliseconds - rate measurement interval. Interval should be at least
1000 / maxRatePerSecond.public void setMaxRatePerSecond(double maxRatePerSecond)
public void throttle(int count)
throws InterruptedException
InterruptedExceptionpublic void throttle()
throws InterruptedException
InterruptedException - when interrupted