Package io.openems.edge.bridge.http.api
Interface BridgeHttpTime
- All Known Subinterfaces:
BridgeHttp
- All Known Implementing Classes:
BridgeHttpImpl
,DummyBridgeHttp
public interface BridgeHttpTime
BridgeHttpTime to handle request to a endpoint based on a time delay.
The calculation when an endpoint gets called is provided in the
DelayTimeProvider
. The
DelayTimeProvider.nextRun(boolean, boolean)
gets called instantly
when the initial method to add the endpoint gets called and then every time
after the last endpoint handle was finished.
So for e. g. if a fixed delay of 1 minute gets provided the time will shift into the back a little bit every time an endpoint gets called because fetching the endpoint and handling it also takes some time.
A simple example to subscribe to an endpoint with 1 minute delay in between would be:
final var delayProvider = DelayTimeProviderChain.fixedDelay(Duration.ofMinutes(1)); this.httpBridge.subscribeTime(delayProvider, "http://127.0.0.1/status", t -> { // process data }, t -> { // handle error });
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
subscribeJsonTime
(DelayTimeProvider delayTimeProvider, BridgeHttp.Endpoint endpoint, ThrowingConsumer<com.google.gson.JsonElement, Exception> onResult, Consumer<Throwable> onError) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProvider
and after every endpoint fetch either theonResult
or theonError
method gets called.default void
subscribeJsonTime
(DelayTimeProvider delayTimeProvider, BridgeHttp.Endpoint endpoint, BiConsumer<com.google.gson.JsonElement, Throwable> action) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProvider
and after every endpoint fetch theaction
gets called either with the result or the error at least one is not null.void
subscribeTime
(BridgeHttpTime.TimeEndpoint endpoint) Subscribes to anBridgeHttpTime.TimeEndpoint
.default void
subscribeTime
(DelayTimeProviderChain onErrorDelay, DelayTimeProviderChain onSuccessDelay, String url, ThrowingConsumer<String, Exception> onResult, Consumer<Throwable> onError) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProviderChain
and after every endpoint fetch either theonResult
or theonError
method gets called.default void
subscribeTime
(DelayTimeProviderChain delay, String url, ThrowingConsumer<String, Exception> onResult) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProviderChain
and after every endpoint fetch either theonResult
or theonError
method gets called.default void
subscribeTime
(DelayTimeProviderChain delay, String url, ThrowingConsumer<String, Exception> onResult, Consumer<Throwable> onError) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProviderChain
and after every endpoint fetch either theonResult
or theonError
method gets called.default void
subscribeTime
(DelayTimeProvider delayTimeProvider, BridgeHttp.Endpoint endpoint, ThrowingConsumer<String, Exception> onResult, Consumer<Throwable> onError) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProvider
and after every endpoint fetch either theonResult
or theonError
method gets called.default void
subscribeTime
(DelayTimeProvider delayTimeProvider, BridgeHttp.Endpoint endpoint, BiConsumer<String, Throwable> action) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProvider
and after every endpoint fetch theaction
gets called either with the result or the error at least one is not null.
-
Method Details
-
subscribeTime
Subscribes to anBridgeHttpTime.TimeEndpoint
. TheBridgeHttpTime.TimeEndpoint.endpoint
gets fetched based on the delayed time provided by theBridgeHttpTime.TimeEndpoint.delayTimeProvider
. After the endpoint gets fetched either theBridgeHttpTime.TimeEndpoint.onResult
or theBridgeHttpTime.TimeEndpoint.onError
gets executed depending on the result.- Parameters:
endpoint
- theBridgeHttpTime.TimeEndpoint
to add a subscription
-
subscribeTime
default void subscribeTime(DelayTimeProvider delayTimeProvider, BridgeHttp.Endpoint endpoint, ThrowingConsumer<String, Exception> onResult, Consumer<Throwable> onError) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProvider
and after every endpoint fetch either theonResult
or theonError
method gets called.- Parameters:
delayTimeProvider
- theDelayTimeProvider
to provided the delay between the fetchesendpoint
- theBridgeHttp.Endpoint
to fetchonResult
- the method to call on successful fetchonError
- the method to call if an error happens during fetching or handling the result
-
subscribeTime
default void subscribeTime(DelayTimeProvider delayTimeProvider, BridgeHttp.Endpoint endpoint, BiConsumer<String, Throwable> action) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProvider
and after every endpoint fetch theaction
gets called either with the result or the error at least one is not null.- Parameters:
delayTimeProvider
- theDelayTimeProvider
to provided the delay between the fetchesendpoint
- theBridgeHttp.Endpoint
to fetchaction
- 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
-
subscribeTime
default void subscribeTime(DelayTimeProviderChain onErrorDelay, DelayTimeProviderChain onSuccessDelay, String url, ThrowingConsumer<String, Exception> onResult, Consumer<Throwable> onError) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProviderChain
and after every endpoint fetch either theonResult
or theonError
method gets called.Note: the first fetch gets triggered immediately
- Parameters:
onErrorDelay
- theDelayTimeProviderChain
when the last fetch was not successfulonSuccessDelay
- theDelayTimeProviderChain
when the last fetch was successfulurl
- the url to fetchonResult
- the method to call on successful fetchonError
- the method to call if an error happens during fetching or handling the result
-
subscribeTime
default void subscribeTime(DelayTimeProviderChain delay, String url, ThrowingConsumer<String, Exception> onResult, Consumer<Throwable> onError) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProviderChain
and after every endpoint fetch either theonResult
or theonError
method gets called.Note: the first fetch gets triggered immediately
- Parameters:
delay
- theDelayTimeProviderChain
between each fetchurl
- the url to fetchonResult
- the method to call on successful fetchonError
- the method to call if an error happens during fetching or handling the result
-
subscribeTime
default void subscribeTime(DelayTimeProviderChain delay, String url, ThrowingConsumer<String, Exception> onResult) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProviderChain
and after every endpoint fetch either theonResult
or theonError
method gets called.Note: the first fetch gets triggered immediately
- Parameters:
delay
- theDelayTimeProviderChain
between each fetchurl
- the url to fetchonResult
- the method to call on successful fetch
-
subscribeJsonTime
default void subscribeJsonTime(DelayTimeProvider delayTimeProvider, BridgeHttp.Endpoint endpoint, ThrowingConsumer<com.google.gson.JsonElement, Exception> onResult, Consumer<Throwable> onError) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProvider
and after every endpoint fetch either theonResult
or theonError
method gets called.- Parameters:
delayTimeProvider
- theDelayTimeProvider
to provided the delay between the fetchesendpoint
- theBridgeHttp.Endpoint
to fetchonResult
- the method to call on successful fetchonError
- the method to call if an error happens during fetching or handling the result
-
subscribeJsonTime
default void subscribeJsonTime(DelayTimeProvider delayTimeProvider, BridgeHttp.Endpoint endpoint, BiConsumer<com.google.gson.JsonElement, Throwable> action) Subscribes to anBridgeHttp.Endpoint
with the delay provided by theDelayTimeProvider
and after every endpoint fetch theaction
gets called either with the result or the error at least one is not null.- Parameters:
delayTimeProvider
- theDelayTimeProvider
to provided the delay between the fetchesendpoint
- theBridgeHttp.Endpoint
to fetchaction
- 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
-