public class UniRetry<T> extends Object
Constructor and Description |
---|
UniRetry(Uni<T> upstream,
Predicate<? super Throwable> predicate) |
Modifier and Type | Method and Description |
---|---|
Uni<T> |
atMost(long numberOfAttempts)
|
Uni<T> |
expireAt(long expireAt)
|
Uni<T> |
expireIn(long expireIn)
|
Uni<T> |
indefinitely()
|
Uni<T> |
until(Predicate<? super Throwable> predicate)
|
Uni<T> |
when(Function<Multi<Throwable>,? extends org.reactivestreams.Publisher<?>> whenStreamFactory)
|
UniRetry<T> |
withBackOff(Duration initialBackOff)
Configures a back-off delay between to attempt to re-subscribe.
|
UniRetry<T> |
withBackOff(Duration initialBackOff,
Duration maxBackOff)
Configures a back-off delay between to attempt to re-subscribe.
|
UniRetry<T> |
withJitter(double jitter)
Configures the random factor when using back-off.
|
public Uni<T> indefinitely()
Uni
resubscribing to the current Uni
until it gets an item (potentially null
)
On every failure, it re-subscribes, indefinitely.Uni
public Uni<T> atMost(long numberOfAttempts)
Uni
resubscribing to the current Uni
at most numberOfAttempts
time, until it
gets an item (potentially null
). On every failure, it re-subscribes.
If the number of attempt is reached, the last failure is propagated.
numberOfAttempts
- the number of attempt, must be greater than zeroUni
retrying at most numberOfAttempts
times to subscribe to the current Uni
until it gets an item. When the number of attempt is reached, the last failure is propagated. If the back-off
has been configured, a delay is introduced between the attempts.public Uni<T> expireAt(long expireAt)
Uni
resubscribing to the current Uni
until expireAt
time or until it
gets an item (potentially null
). On every failure, it re-subscribes.
If expiration time is passed, the last failure is propagated. Backoff must be configured.
expireAt
- absolute time in millis that specifies when to give upUni
retrying to subscribe to the current Uni
until it gets an item or until
expiration expireAt
. When the expiration is reached, the last failure is propagated.IllegalArgumentException
- if back off not configured,public Uni<T> expireIn(long expireIn)
Uni
resubscribing to the current Uni
until expireIn
time or until it
gets an item (potentially null
). On every failure, it re-subscribes.
If expiration time is passed, the last failure is propagated. Backoff must be configured.
expireIn
- relative time in millis that specifies when to give upUni
retrying to subscribe to the current Uni
until it gets an item or until
expiration expireIn
. When the expiration is reached, the last failure is propagated.IllegalArgumentException
- if back off not configured,public Uni<T> until(Predicate<? super Throwable> predicate)
Uni
resubscribing to the current Uni
until the given predicate returns false
.
The predicate is called with the failure emitted by the current Uni
.predicate
- the predicate that determines if a re-subscription may happen in case of a specific failure,
must not be null
. If the predicate returns true
for the given failure, a
re-subscription is attempted.Uni
instancepublic Uni<T> when(Function<Multi<Throwable>,? extends org.reactivestreams.Publisher<?>> whenStreamFactory)
Uni
resubscribing to the current Uni
when the Publisher
produced by the
given method emits an item.
As atMost(long)
, on every failure, it re-subscribes. However, a delay is introduced before
re-subscribing. The re-subscription happens when the produced streams emits an item. If this stream fails,
the produced Uni
propagates a failure. It the streams completes, the produced Uni
propagates
null
.public UniRetry<T> withBackOff(Duration initialBackOff)
initialBackOff
- the initial back-off duration, must not be null
, must not be negative.public UniRetry<T> withBackOff(Duration initialBackOff, Duration maxBackOff)
maxBackOff
.initialBackOff
- the initial back-off duration, must not be null
, must not be negative.maxBackOff
- the max back-off duration, must not be null
, must not be negative.Copyright © 2019–2020 SmallRye. All rights reserved.