public final class RepeatStrategies
extends java.lang.Object
Publisher.repeatWhen(IntFunction)
,
Single.repeatWhen(IntFunction)
and Completable.repeatWhen(IntFunction)
or in general.Modifier and Type | Class and Description |
---|---|
static class |
RepeatStrategies.TerminateRepeatException
An
Exception instance used to indicate termination of repeats. |
Modifier and Type | Method and Description |
---|---|
static java.util.function.IntFunction<Completable> |
repeatWithConstantBackoff(int maxRepeats,
java.time.Duration backoff,
Executor timerExecutor)
Creates a new repeat function that adds the passed constant
Duration as delay between repeats. |
static java.util.function.IntFunction<Completable> |
repeatWithExponentialBackoff(int maxRepeats,
java.time.Duration initialDelay,
Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats.
|
static java.util.function.IntFunction<Completable> |
repeatWithExponentialBackoffAndJitter(int maxRepeats,
java.time.Duration initialDelay,
Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats.
|
public static java.util.function.IntFunction<Completable> repeatWithConstantBackoff(int maxRepeats, java.time.Duration backoff, Executor timerExecutor)
Duration
as delay between repeats.maxRepeats
- Maximum number of allowed repeats, after which the returned IntFunction
will return
a failed Completable
with RepeatStrategies.TerminateRepeatException
as the cause.backoff
- Constant Duration
of backoff between repeats.timerExecutor
- Executor
to be used to schedule timers for backoff.IntFunction
to be used for repeats which given a repeat count returns a Completable
that terminates successfully when the source has to be repeated or terminates with error if the source should not
be repeated.public static java.util.function.IntFunction<Completable> repeatWithExponentialBackoff(int maxRepeats, java.time.Duration initialDelay, Executor timerExecutor)
initialDelay
which is increased exponentially for subsequent repeats.
This method may not attempt to check for overflow if the repeat count is high enough that an exponential
delay causes Long
overflow.
maxRepeats
- Maximum number of allowed repeats, after which the returned IntFunction
will return
a failed Completable
with RepeatStrategies.TerminateRepeatException
as the cause.initialDelay
- Delay Duration
for the first repeat and increased exponentially with each repeat.timerExecutor
- Executor
to be used to schedule timers for backoff.IntFunction
to be used for repeats which given a repeat count returns a Completable
that terminates successfully when the source has to be repeated or terminates with error if the source should not
be repeated.public static java.util.function.IntFunction<Completable> repeatWithExponentialBackoffAndJitter(int maxRepeats, java.time.Duration initialDelay, Executor timerExecutor)
initialDelay
which is increased exponentially for subsequent repeats.
This additionally adds a "Full Jitter" for the backoff as described
here.
This method may not attempt to check for overflow if the repeat count is high enough that an exponential delay
causes Long
overflow.
maxRepeats
- Maximum number of allowed repeats, after which the returned IntFunction
will return
a failed Completable
with RepeatStrategies.TerminateRepeatException
as the cause.initialDelay
- Delay Duration
for the first repeat and increased exponentially with each repeat.timerExecutor
- Executor
to be used to schedule timers for backoff.IntFunction
to be used for repeats which given a repeat count returns a Completable
that terminates successfully when the source has to be repeated or terminates with error if the source should not
be repeated.