Class SimpleRateGate
java.lang.Object
com.sportradar.livedata.sdk.common.rategate.RateGateBase
com.sportradar.livedata.sdk.common.rategate.SimpleRateGate
- All Implemented Interfaces:
RateGate
-
Field Summary
Fields inherited from class com.sportradar.livedata.sdk.common.rategate.RateGateBase
listener, listenerLock
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleRateGate
(int number, org.joda.time.Duration duration, ScheduledExecutorService scheduler, String rateGateName) Construct a SimpleRateGate. -
Method Summary
Modifier and TypeMethodDescriptionorg.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.Methods inherited from class com.sportradar.livedata.sdk.common.rategate.RateGateBase
howLongToWait, setListener, waitToProceed, waitToProceed
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sportradar.livedata.sdk.common.rategate.RateGate
howLongToWait, setListener, waitToProceed, waitToProceed
-
Constructor Details
-
SimpleRateGate
public SimpleRateGate(int number, org.joda.time.Duration duration, ScheduledExecutorService scheduler, String rateGateName) Construct a SimpleRateGate.- Parameters:
number
- - number of elementsduration
- - that can pass in this periodscheduler
- - task schedulerrateGateName
- limiter name for easier identification
-
-
Method Details
-
waitToProceed
Description copied from interface:RateGate
Block when configured rate-limits are exceeded.- Specified by:
waitToProceed
in interfaceRateGate
- Parameters:
amount
- - number of elements- Throws:
InterruptedException
- when somebody interrupted the waiting
-
waitToProceed
Block when configured rate-limits are exceeded.- Specified by:
waitToProceed
in interfaceRateGate
- Specified by:
waitToProceed
in classRateGateBase
- Parameters:
amount
- - number of elementswait
- - the maximum amount of time to wait, negative means infinity- Returns:
- true when we passed the gate; false when a timeout occurred
- Throws:
InterruptedException
- when somebody interrupted the waiting
-
howLongToWait
public org.joda.time.Duration howLongToWait(int amount) Approximately how long will I have to wait?- Specified by:
howLongToWait
in interfaceRateGate
- Specified by:
howLongToWait
in classRateGateBase
- Parameters:
amount
- - number of elements- Returns:
- - a non-negative amount of time, zero means no need to wait.
-