use of io.kestra.core.services.FlowListenersInterface in project kestra by kestra-io.
the class FlowListenersRestoreCommand method call.
@Override
public Integer call() throws Exception {
super.call();
FlowListenersInterface flowListeners = applicationContext.getBean(FlowListenersInterface.class);
AtomicReference<ZonedDateTime> lastTime = new AtomicReference<>(ZonedDateTime.now());
flowListeners.run();
flowListeners.listen(flows -> {
long count = flows.stream().filter(flow -> !flow.isDeleted()).count();
stdOut("Received {0} active flows", count);
if (count > 0) {
lastTime.set(ZonedDateTime.now());
}
});
// we can't know when it's over, wait no more flow received
Await.until(() -> lastTime.get().compareTo(ZonedDateTime.now().minus(this.timeout)) < 0);
return 0;
}
Aggregations