Interface BridgeHttpCycle
- All Known Subinterfaces:
BridgeHttp
- All Known Implementing Classes:
BridgeHttpImpl
,DummyBridgeHttp
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.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
subscribeCycle
(int cycle, String url, ThrowingConsumer<String, Exception> result, Consumer<Throwable> onError) Subscribes to one http endpoint.default void
subscribeCycle
(int cycle, String url, BiConsumer<String, Throwable> action) Subscribes to one http endpoint.default void
subscribeCycle
(int cycle, String url, Consumer<String> result) Subscribes to one http endpoint.void
subscribeCycle
(BridgeHttpCycle.CycleEndpoint endpoint) Subscribes to one http endpoint.default void
subscribeEveryCycle
(String url, ThrowingConsumer<String, Exception> result, Consumer<Throwable> onError) Subscribes to one http endpoint.default void
subscribeEveryCycle
(String url, BiConsumer<String, Throwable> action) Subscribes to one http endpoint.default void
subscribeEveryCycle
(String url, Consumer<String> result) Subscribes to one http endpoint.default void
subscribeJsonCycle
(int cycle, String url, ThrowingConsumer<com.google.gson.JsonElement, Exception> result, Consumer<Throwable> onError) Subscribes to one http endpoint.default void
subscribeJsonCycle
(int cycle, String url, BiConsumer<com.google.gson.JsonElement, Throwable> action) Subscribes to one http endpoint.default void
subscribeJsonEveryCycle
(String url, ThrowingConsumer<com.google.gson.JsonElement, Exception> result, Consumer<Throwable> onError) Subscribes to one http endpoint.default void
subscribeJsonEveryCycle
(String url, BiConsumer<com.google.gson.JsonElement, Throwable> action) Subscribes to one http endpoint.
-
Method Details
-
subscribeCycle
Subscribes to one http endpoint.- Parameters:
endpoint
- theBridgeHttpCycle.CycleEndpoint
configuration
-
subscribeCycle
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 requestsurl
- the url of the enpointresult
- 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 requestsurl
- the url of the enpointresult
- the consumer to call on every successful resultonError
- the consumer to call on a error
-
subscribeCycle
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 requestsurl
- the url of the enpointaction
- 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 enpointresult
- the consumer to call on every successful resultonError
- the consumer to call on a error
-
subscribeEveryCycle
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 enpointaction
- 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
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 enpointresult
- 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 requestsurl
- the url of the enpointresult
- the consumer to call on every successful resultonError
- 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 requestsurl
- the url of the enpointaction
- 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 enpointresult
- the consumer to call on every successful resultonError
- 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 enpointaction
- 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
-