Interface BridgeHttpCycle

All Known Subinterfaces:
BridgeHttp
All Known Implementing Classes:
BridgeHttpImpl, DummyBridgeHttp

public interface BridgeHttpCycle
BridgeHttpCycle to handle request to a endpoint based on the cycle.

If a request is scheduled every cycle and the request does take longer than one cycle it is not executed multiple times instead it waits until the last request is finished and will be executed with the next cycle.

A simple example to subscribe to an endpoint every cycle would be:

 this.httpBridge.subscribeEveryCycle("http://127.0.0.1/status", t -> {
        // process data
 }, t -> {
        // handle error
 });
 

If an endpoint does not require to be called every cycle it can also be configured with e. g. subscribeCycle(int, String, Consumer) where the first value could be 5 then the request gets triggered every 5th cycle.

  • Method Details

    • subscribeCycle

      void subscribeCycle(BridgeHttpCycle.CycleEndpoint endpoint)
      Subscribes to one http endpoint.
      Parameters:
      endpoint - the BridgeHttpCycle.CycleEndpoint configuration
    • subscribeCycle

      default void subscribeCycle(int cycle, String url, Consumer<String> result)
      Subscribes to one http endpoint.

      Tries to fetch data every n-cycle. If receiving data takes more than n-cycle the next get request to the url gets send when the last was finished either successfully or with a timeout.

      Parameters:
      cycle - the number of cycles to wait between requests
      url - the url of the enpoint
      result - the consumer to call on every successful result
    • subscribeCycle

      default void subscribeCycle(int cycle, String url, ThrowingConsumer<String,Exception> result, Consumer<Throwable> onError)
      Subscribes to one http endpoint.

      Tries to fetch data every n-cycle. If receiving data takes more than n-cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      cycle - the number of cycles to wait between requests
      url - the url of the enpoint
      result - the consumer to call on every successful result
      onError - the consumer to call on a error
    • subscribeCycle

      default void subscribeCycle(int cycle, String url, BiConsumer<String,Throwable> action)
      Subscribes to one http endpoint.

      Tries to fetch data every n-cycle. If receiving data takes more than n-cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      cycle - the number of cycles to wait between requests
      url - the url of the enpoint
      action - the action to perform; the first is the result of the endpoint if existing and the second argument is passed if an error happend. One of the params is always null and one not
    • subscribeEveryCycle

      default void subscribeEveryCycle(String url, ThrowingConsumer<String,Exception> result, Consumer<Throwable> onError)
      Subscribes to one http endpoint.

      Tries to fetch data every cycle. If receiving data takes more than one cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      url - the url of the enpoint
      result - the consumer to call on every successful result
      onError - the consumer to call on a error
    • subscribeEveryCycle

      default void subscribeEveryCycle(String url, BiConsumer<String,Throwable> action)
      Subscribes to one http endpoint.

      Tries to fetch data every cycle. If receiving data takes more than one cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      url - the url of the enpoint
      action - the action to perform; the first is the result of the endpoint if existing and the second argument is passed if an error happend. One of the params is always null and one not
    • subscribeEveryCycle

      default void subscribeEveryCycle(String url, Consumer<String> result)
      Subscribes to one http endpoint.

      Tries to fetch data every cycle. If receiving data takes more than one cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      url - the url of the enpoint
      result - the consumer to call on every successful result
    • subscribeJsonCycle

      default void subscribeJsonCycle(int cycle, String url, ThrowingConsumer<com.google.gson.JsonElement,Exception> result, Consumer<Throwable> onError)
      Subscribes to one http endpoint.

      Tries to fetch data every n-cycle. If receiving data takes more than n-cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      cycle - the number of cycles to wait between requests
      url - the url of the enpoint
      result - the consumer to call on every successful result
      onError - the consumer to call on a error
    • subscribeJsonCycle

      default void subscribeJsonCycle(int cycle, String url, BiConsumer<com.google.gson.JsonElement,Throwable> action)
      Subscribes to one http endpoint.

      Tries to fetch data every n-cycle. If receiving data takes more than n-cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      cycle - the number of cycles to wait between requests
      url - the url of the enpoint
      action - the action to perform; the first is the result of the endpoint if existing and the second argument is passed if an error happend. One of the params is always null and one not
    • subscribeJsonEveryCycle

      default void subscribeJsonEveryCycle(String url, ThrowingConsumer<com.google.gson.JsonElement,Exception> result, Consumer<Throwable> onError)
      Subscribes to one http endpoint.

      Tries to fetch data every cycle. If receiving data takes more than one cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      url - the url of the enpoint
      result - the consumer to call on every successful result
      onError - the consumer to call on a error
    • subscribeJsonEveryCycle

      default void subscribeJsonEveryCycle(String url, BiConsumer<com.google.gson.JsonElement,Throwable> action)
      Subscribes to one http endpoint.

      Tries to fetch data every cycle. If receiving data takes more than one cycle the next get request to the url gets send when the last was finished either successfully or with an error.

      Parameters:
      url - the url of the enpoint
      action - the action to perform; the first is the result of the endpoint if existing and the second argument is passed if an error happend. One of the params is always null and one not