public class SimpleRateGate extends RateGateBase implements RateGate
Constructor and Description |
---|
SimpleRateGate(int number,
org.joda.time.Duration duration,
ScheduledExecutorService scheduler,
String rateGateName)
Construct a SimpleRateGate.
|
Modifier and Type | Method and Description |
---|---|
org.joda.time.Duration |
howLongToWait(int amount)
Approximately how long will I have to wait?
|
void |
waitToProceed(int amount)
Block when configured rate-limits are exceeded.
|
boolean |
waitToProceed(int amount,
org.joda.time.Duration wait)
Block when configured rate-limits are exceeded.
|
howLongToWait, setListener, waitToProceed, waitToProceed
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
howLongToWait, setListener, waitToProceed, waitToProceed
public SimpleRateGate(int number, org.joda.time.Duration duration, ScheduledExecutorService scheduler, String rateGateName)
number
- - number of elementsduration
- - that can pass in this periodscheduler
- - task schedulerrateGateName
- limiter name for easier identificationpublic void waitToProceed(int amount) throws InterruptedException
RateGate
waitToProceed
in interface RateGate
amount
- - number of elementsInterruptedException
- when somebody interrupted the waitingpublic boolean waitToProceed(int amount, org.joda.time.Duration wait) throws InterruptedException
waitToProceed
in interface RateGate
waitToProceed
in class RateGateBase
amount
- - number of elementswait
- - the maximum amount of time to wait, negative means infinityInterruptedException
- when somebody interrupted the waitingpublic org.joda.time.Duration howLongToWait(int amount)
howLongToWait
in interface RateGate
howLongToWait
in class RateGateBase
amount
- - number of elementsCopyright © 2013–2023. All rights reserved.