Package io.smallrye.mutiny.groups
Class UniOnTimeout<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.UniOnTimeout<T>
-
public class UniOnTimeout<T> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description UniOnTimeout(Uni<T> upstream, java.time.Duration timeout, java.util.concurrent.ScheduledExecutorService executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UniOnTimeout<T>
after(java.time.Duration timeout)
Configures the timeout duration.Uni<T>
fail()
Uni<T>
failWith(java.lang.Throwable failure)
Uni<T>
failWith(java.util.function.Supplier<? extends java.lang.Throwable> supplier)
UniOnTimeout<T>
on(java.util.concurrent.ScheduledExecutorService executor)
Configures on which executor the timeout is measured.Uni<T>
recoverWithItem(java.util.function.Supplier<T> supplier)
Uni<T>
recoverWithItem(T fallback)
Uni<T>
recoverWithUni(Uni<? extends T> fallback)
Uni<T>
recoverWithUni(java.util.function.Supplier<Uni<? extends T>> supplier)
-
-
-
Method Detail
-
after
@CheckReturnValue public UniOnTimeout<T> after(java.time.Duration timeout)
Configures the timeout duration.- Parameters:
timeout
- the timeout, must not benull
, must be strictly positive.- Returns:
- a new
UniOnTimeout
-
on
@CheckReturnValue public UniOnTimeout<T> on(java.util.concurrent.ScheduledExecutorService executor)
Configures on which executor the timeout is measured. Note that this executor is also going to be used to fire theTimeout
failure event.- Parameters:
executor
- the executor to use, must not benull
- Returns:
- a new
UniOnTimeout
-
failWith
@CheckReturnValue public Uni<T> failWith(java.util.function.Supplier<? extends java.lang.Throwable> supplier)
-
recoverWithItem
@CheckReturnValue public Uni<T> recoverWithItem(T fallback)
Produces a newUni
firing a fallback item when the currentUni
the upstreamUni
do not emit an item before the timeout.The fallback item (potentially
null
) is used as item by the producedUni
.- Parameters:
fallback
- the fallback value, may benull
- Returns:
- the new
Uni
-
recoverWithItem
@CheckReturnValue public Uni<T> recoverWithItem(java.util.function.Supplier<T> supplier)
Produces a newUni
firing a fallback item supplied by the given supplier when the currentUni
times out. The produced item (potentiallynull
) is fired as item by the producedUni
. Note that if the supplier throws an exception, the producedUni
emits a failure.- Parameters:
supplier
- the fallback supplier, may benull
- Returns:
- the new
Uni
-
recoverWithUni
@CheckReturnValue public Uni<T> recoverWithUni(java.util.function.Supplier<Uni<? extends T>> supplier)
Produces a newUni
providing a fallbackUni
when the currentUni
times out. The fallback is produced using the given supplier, and it called when the failure is caught. The producedUni
is used instead of the currentUni
.- Parameters:
supplier
- the fallback supplier, must not benull
, must not producenull
- Returns:
- the new
Uni
-
-