All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vtom.vertx.pipeline.component.periodic.VtmPeriodicStream Maven / Gradle / Ivy

There is a newer version: 1.1-beta
Show newest version
package io.vtom.vertx.pipeline.component.periodic;

import io.vertx.core.*;
import io.vtom.vertx.pipeline.step.StepOUT;

public class VtmPeriodicStream extends AbstractPeriodic {

  private long delay;
  private Handler exceptionHandler;
  private Handler handler;
  private Long fetch;
  private Handler endHandler;


  public VtmPeriodicStream(long delay) {
    this.delay = delay;
  }

  public VtmPeriodicStream exceptionHandler(Handler exceptionHandler) {
    this.exceptionHandler = exceptionHandler;
    return this;
  }

  public VtmPeriodicStream handler(Handler handler) {
    this.handler = handler;
    return this;
  }

  public VtmPeriodicStream fetch(Long fetch) {
    this.fetch = fetch;
    return this;
  }

  public VtmPeriodicStream endHandler(Handler endHandler) {
    this.endHandler = endHandler;
    return this;
  }

  @Override
  public StepOUT out() {
    return new VtmPeriodicOut(stepskips()) {
      @Override
      public void execute(Vertx vertx, Handler> _handler) {
        TimeoutStream stream = vertx.periodicStream(delay);
        if (exceptionHandler != null)
          stream.exceptionHandler(exceptionHandler);
        if (endHandler != null)
          stream.endHandler(endHandler);
        if (fetch != null)
          stream.fetch(fetch);
        if (handler != null)
          stream.handler(handler);

        _handler.handle(Future.succeededFuture(stream));
      }
    };
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy