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
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
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 theTimeoutfailure event.- Parameters:
executor- the executor to use, must not benull- Returns:
- a new
UniOnTimeout
-
failWith
public Uni<T> failWith(java.util.function.Supplier<? extends java.lang.Throwable> supplier)
-
recoverWithItem
public Uni<T> recoverWithItem(T fallback)
Produces a newUnifiring a fallback item when the currentUnithe upstreamUnido 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
public Uni<T> recoverWithItem(java.util.function.Supplier<T> supplier)
Produces a newUnifiring a fallback item supplied by the given supplier when the currentUnitimes out. The produced item (potentiallynull) is fired as item by the producedUni. Note that if the supplier throws an exception, the producedUniemits a failure.- Parameters:
supplier- the fallback supplier, may benull- Returns:
- the new
Uni
-
recoverWithUni
public Uni<T> recoverWithUni(java.util.function.Supplier<Uni<? extends T>> supplier)
Produces a newUniproviding a fallbackUniwhen the currentUnitimes out. The fallback is produced using the given supplier, and it called when the failure is caught. The producedUniis used instead of the currentUni.- Parameters:
supplier- the fallback supplier, must not benull, must not producenull- Returns:
- the new
Uni
-
-