public class RateLimiterOperator extends Object
class MyPunchlet extends Punchlet {
RateLimiterOperator rateLimiter = new RateLimiterOperator(TimeUnit.MINUTES, 5);
public void execute(Tuple root) {
...
if (rateLimiter.pass()) {
// Do something, this will execute only once every 5 minutes.
}
}
}
Constructor and Description |
---|
RateLimiterOperator(TimeUnit unit,
long value)
Create a new operator with some delay
|
Modifier and Type | Method and Description |
---|---|
boolean |
pass()
Evaluate the operator.
|
boolean |
run(Runnable runnable)
Run the passed Runnable once in the operator interval.
|
public RateLimiterOperator(TimeUnit unit, long value)
unit
- the TimeUnit in which the interval is definedvalue
- the interval valuepublic boolean pass()
public boolean run(Runnable runnable)
runnable
- the runnableCopyright © 2022. All rights reserved.