K
- type of the keyOM
- type of the outputpublic interface TimerFunction<K,OM>
Example of a FlatMapFunction
with timer:
public class ExampleTimerFn implements FlatMapFunction<String, String>, TimerFunction<String, String> {
public void registerTimer(TimerRegistry timerRegistry) {
long time = System.currentTimeMillis() + 5000; // fire after 5 sec
timerRegistry.register("example-timer", time);
}
public Collection<String> apply(String s) {
...
}
public Collection<String> onTimer(String key, long timestamp) {
// example-timer fired
...
}
}
Modifier and Type | Method and Description |
---|---|
java.util.Collection<OM> |
onTimer(K key,
long timestamp)
Returns the output after the timer with key fires.
|
void |
registerTimer(TimerRegistry<K> timerRegistry)
Registers any epoch-time timers using the registry
|
void registerTimer(TimerRegistry<K> timerRegistry)
timerRegistry
- a keyed TimerRegistry