Class UniAwait<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.UniAwait<T>
-
- Type Parameters:
T
- the type of item
public class UniAwait<T> extends java.lang.Object
Waits and returns the item emitted by theUni
. If theUni
receives a failure, the failure is thrown.This class lets you configure how to retrieves the item of a
Uni
by blocking the caller thread.- See Also:
Uni.await()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UniAwaitOptional<T>
asOptional()
Indicates that you are awaiting for the item event of the attachedUni
wrapped into anOptional
.T
atMost(java.time.Duration duration)
Subscribes to theUni
and waits (blocking the caller thread) at most the given duration until an item or failure is fired by the upstream uni.T
indefinitely()
Subscribes to theUni
and waits (blocking the caller thread) indefinitely until aitem
event is fired or afailure
event is fired by the upstream uni.
-
-
-
Method Detail
-
indefinitely
public T indefinitely()
Subscribes to theUni
and waits (blocking the caller thread) indefinitely until aitem
event is fired or afailure
event is fired by the upstream uni.If the
Uni
fires an item, it returns that item, potentiallynull
if the operation returnsnull
. If theUni
fires a failure, the original exception is thrown (wrapped in aCompletionException
it's a checked exception).Note that each call to this method triggers a new subscription.
- Returns:
- the item from the
Uni
, potentiallynull
-
atMost
public T atMost(java.time.Duration duration)
Subscribes to theUni
and waits (blocking the caller thread) at most the given duration until an item or failure is fired by the upstream uni.If the
Uni
fires an item, it returns that item, potentiallynull
if the operation returnsnull
. If theUni
fires a failure, the original exception is thrown (wrapped in aCompletionException
it's a checked exception). If the timeout is reached before completion, aTimeoutException
is thrown.Note that each call to this method triggers a new subscription.
- Parameters:
duration
- the duration, must not benull
, must not be negative or zero.- Returns:
- the item from the
Uni
, potentiallynull
-
asOptional
public UniAwaitOptional<T> asOptional()
Indicates that you are awaiting for the item event of the attachedUni
wrapped into anOptional
. So if theUni
firesnull
as item, you receive an emptyOptional
.- Returns:
- the
UniAwaitOptional
configured to produce anOptional
.
-
-