Package org.hawaiiframework.async
Class AsyncUtil
- java.lang.Object
-
- org.hawaiiframework.async.AsyncUtil
-
public final class AsyncUtil extends Object
Utility class to wrap an asynchronous call and catch all errors.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
expectErrorInTimeoutOrStopWaiting(@NotNull Long timeout, @NotNull TimeUnit unit, @NotNull CompletableFuture<?> future)
This call waits the provided timeout for an error to occur.static void
expectErrorInTimeoutOrStopWaiting(@NotNull Long timeout, @NotNull TimeUnit unit, @NotNull CompletableFuture<?>... futures)
Delegates toCompletableFuture.get(long, TimeUnit)
}.static <T> void
expectErrorInTimeoutOrStopWaiting(@NotNull Long timeout, @NotNull TimeUnit unit, @NotNull List<CompletableFuture<T>> futures)
Delegates toCompletableFuture.get(long, TimeUnit)
}.static <T> CompletableFuture<T>
invoke(boolean logError, AsyncCallable<T> body)
Invoke the body and return the response wrapped as a completable future..static <T> CompletableFuture<T>
invoke(AsyncCallable<T> body)
Invoke the body and return the response wrapped as a completable future..static CompletableFuture<VoidResult>
invokeAndLogError(AsyncInvoke body)
Invoke the body and return the response wrapped as a completable future..
-
-
-
Method Detail
-
invoke
public static <T> CompletableFuture<T> invoke(AsyncCallable<T> body)
Invoke the body and return the response wrapped as a completable future..
-
invoke
public static <T> CompletableFuture<T> invoke(boolean logError, AsyncCallable<T> body)
Invoke the body and return the response wrapped as a completable future..
-
invokeAndLogError
public static CompletableFuture<VoidResult> invokeAndLogError(AsyncInvoke body)
Invoke the body and return the response wrapped as a completable future..
-
expectErrorInTimeoutOrStopWaiting
public static <T> void expectErrorInTimeoutOrStopWaiting(@NotNull @NotNull Long timeout, @NotNull @NotNull TimeUnit unit, @NotNull @NotNull List<CompletableFuture<T>> futures)
Delegates toCompletableFuture.get(long, TimeUnit)
}.
-
expectErrorInTimeoutOrStopWaiting
public static void expectErrorInTimeoutOrStopWaiting(@NotNull @NotNull Long timeout, @NotNull @NotNull TimeUnit unit, @NotNull @NotNull CompletableFuture<?>... futures)
Delegates toCompletableFuture.get(long, TimeUnit)
}.
-
expectErrorInTimeoutOrStopWaiting
public static void expectErrorInTimeoutOrStopWaiting(@NotNull @NotNull Long timeout, @NotNull @NotNull TimeUnit unit, @NotNull @NotNull CompletableFuture<?> future)
This call waits the provided timeout for an error to occur. After the timeout, this call continues with the flow without waiting for the actual result. This is to prevent waiting for backend calls to return, while we are not interested in the return value for the current flow. (e.g. send mail via BSL). The assumption is that if no error is returned within the timeout, the call will be successful. Delegates toCompletableFuture.get(long, TimeUnit)
}.
-
-