Class RateGateBase
- java.lang.Object
-
- com.sportradar.livedata.sdk.common.rategate.RateGateBase
-
- All Implemented Interfaces:
RateGate
- Direct Known Subclasses:
CombinedRateGate
,NullRateGate
,SimpleRateGate
public abstract class RateGateBase extends Object implements RateGate
-
-
Field Summary
Fields Modifier and Type Field Description protected RateGateListener
listener
protected Object
listenerLock
-
Constructor Summary
Constructors Constructor Description RateGateBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description org.joda.time.Duration
howLongToWait()
Approximately how long will I have to wait?abstract org.joda.time.Duration
howLongToWait(int amount)
Approximately how long will I have to wait?void
setListener(RateGateListener listener)
Set the event listenervoid
waitToProceed()
Block when configured rate-limits are exceeded.abstract boolean
waitToProceed(int amount, org.joda.time.Duration wait)
Block when configured rate-limits are exceeded.boolean
waitToProceed(org.joda.time.Duration wait)
Block when configured rate-limits are exceeded.-
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
waitToProceed
-
-
-
-
Field Detail
-
listenerLock
protected final Object listenerLock
-
listener
protected RateGateListener listener
-
-
Method Detail
-
waitToProceed
public void waitToProceed() throws InterruptedException
Description copied from interface:RateGate
Block when configured rate-limits are exceeded.- Specified by:
waitToProceed
in interfaceRateGate
- Throws:
InterruptedException
- when somebody interrupted the waiting
-
waitToProceed
public boolean waitToProceed(org.joda.time.Duration wait) throws InterruptedException
Block when configured rate-limits are exceeded.- Specified by:
waitToProceed
in interfaceRateGate
- Parameters:
wait
- - when specified this means the maximum amount of time to wait- Returns:
- true when we passed the gate; false when a timeout occured
- Throws:
InterruptedException
- when somebody interrupted the waiting
-
waitToProceed
public abstract boolean waitToProceed(int amount, org.joda.time.Duration wait) throws InterruptedException
Block when configured rate-limits are exceeded.- Specified by:
waitToProceed
in interfaceRateGate
- 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 occured
- Throws:
InterruptedException
- when somebody interrupted the waiting
-
howLongToWait
public org.joda.time.Duration howLongToWait()
Approximately how long will I have to wait?- Specified by:
howLongToWait
in interfaceRateGate
- Returns:
- - a non-negative amount of time, zero means no need to wait.
-
howLongToWait
public abstract org.joda.time.Duration howLongToWait(int amount)
Approximately how long will I have to wait?- Specified by:
howLongToWait
in interfaceRateGate
- Parameters:
amount
- - number of elements- Returns:
- - a non-negative amount of time, zero means no need to wait.
-
setListener
public void setListener(RateGateListener listener)
Set the event listener- Specified by:
setListener
in interfaceRateGate
- Parameters:
listener
- - new listener
-
-