Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public interface RealtimeContext extends TransformContext {
  ...
 
  // set poll frequency. Will try to run every x amount of time
  void setPollFrequency(long freg);
  // set poll delay in the given time unit
  void setPollFrequency(long duration, TimeUnit unit);
 
  void getPollFrequency(); 
  // get poll delay in the given time unit
  long getPollFrequency(TimeUnit unit);
 
  // set poll delay in milliseconds
  void setPollDelay(long duration);
 
  // set poll delay in the given time unit
  void setPollDelay(long duration, TimeUnit unit);
 
  // get poll delay in milliseconds
  long getPollDelay();
 
  // get poll delay in the given time unit
  long getPollDelay(TimeUnit unit);
}
 
@Override
public abstract SourceState poll(Emitter<T> writer, SourceState currentState) throws Exception {
  try {
    // perform request
    context.setPollDelay(100);
  } catch (Exception e) {
    context.setPollDelay(context.getPollDelay() * 2);
    return currentState;
  }
}

...