Package io.servicetalk.concurrent.api
Class RepeatStrategies
- java.lang.Object
-
- io.servicetalk.concurrent.api.RepeatStrategies
-
public final class RepeatStrategies extends java.lang.Object
A set of strategies to use for repeating withPublisher.repeatWhen(IntFunction)
,Single.repeatWhen(IntFunction)
andCompletable.repeatWhen(IntFunction)
or in general.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RepeatStrategies.TerminateRepeatException
AnException
instance used to indicate termination of repeats.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.function.IntFunction<Completable>
repeatWithConstantBackoffDeltaJitter(int maxRepeats, java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new repeat function that adds the passed constantDuration
as delay between repeats.static java.util.function.IntFunction<Completable>
repeatWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new repeat function that adds the passed constantDuration
as delay between repeats.static java.util.function.IntFunction<Completable>
repeatWithConstantBackoffFullJitter(int maxRepeats, java.time.Duration delay, Executor timerExecutor)
Creates a new repeat function that adds the passed constantDuration
as delay between repeats.static java.util.function.IntFunction<Completable>
repeatWithConstantBackoffFullJitter(java.time.Duration delay, Executor timerExecutor)
Creates a new repeat function that adds the passed constantDuration
as delay between repeats.static java.util.function.IntFunction<Completable>
repeatWithExponentialBackoffDeltaJitter(int maxRepeats, java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats.static java.util.function.IntFunction<Completable>
repeatWithExponentialBackoffDeltaJitter(java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats.static java.util.function.IntFunction<Completable>
repeatWithExponentialBackoffFullJitter(int maxRepeats, java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats.static java.util.function.IntFunction<Completable>
repeatWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats.
-
-
-
Method Detail
-
repeatWithConstantBackoffFullJitter
public static java.util.function.IntFunction<Completable> repeatWithConstantBackoffFullJitter(java.time.Duration delay, Executor timerExecutor)
Creates a new repeat function that adds the passed constantDuration
as delay between repeats.- Parameters:
delay
- ConstantDuration
of delay between repeats.timerExecutor
-Executor
to be used to schedule timers for delay.- Returns:
- An
IntFunction
to be used for repeats which given a repeat count returns aCompletable
that terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithConstantBackoffFullJitter
public static java.util.function.IntFunction<Completable> repeatWithConstantBackoffFullJitter(int maxRepeats, java.time.Duration delay, Executor timerExecutor)
Creates a new repeat function that adds the passed constantDuration
as delay between repeats.- Parameters:
maxRepeats
- Maximum number of allowed repeats, after which the returnedIntFunction
will return a failedCompletable
withRepeatStrategies.TerminateRepeatException
as the cause.delay
- ConstantDuration
of delay between repeats.timerExecutor
-Executor
to be used to schedule timers for delay.- Returns:
- An
IntFunction
to be used for repeats which given a repeat count returns aCompletable
that terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithConstantBackoffDeltaJitter
public static java.util.function.IntFunction<Completable> repeatWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new repeat function that adds the passed constantDuration
as delay between repeats.- Parameters:
delay
- ConstantDuration
of delay between repeats.jitter
- The jitter to apply todelay
on each repeat.timerExecutor
-Executor
to be used to schedule timers for delay.- Returns:
- An
IntFunction
to be used for repeats which given a repeat count returns aCompletable
that terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithConstantBackoffDeltaJitter
public static java.util.function.IntFunction<Completable> repeatWithConstantBackoffDeltaJitter(int maxRepeats, java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new repeat function that adds the passed constantDuration
as delay between repeats.- Parameters:
maxRepeats
- Maximum number of allowed repeats, after which the returnedIntFunction
will return a failedCompletable
withRepeatStrategies.TerminateRepeatException
as the cause.delay
- ConstantDuration
of delay between repeats.jitter
- The jitter to apply todelay
on each repeat.timerExecutor
-Executor
to be used to schedule timers for delay.- Returns:
- An
IntFunction
to be used for repeats which given a repeat count returns aCompletable
that terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithExponentialBackoffFullJitter
public static java.util.function.IntFunction<Completable> repeatWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats. For first repeat, the delay isinitialDelay
which is increased exponentially for subsequent repeats. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
initialDelay
- DelayDuration
for the first repeat and increased exponentially with each repeat.maxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff.- Returns:
- An
IntFunction
to be used for repeats which given a repeat count returns aCompletable
that terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithExponentialBackoffFullJitter
public static java.util.function.IntFunction<Completable> repeatWithExponentialBackoffFullJitter(int maxRepeats, java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats. For first repeat, the delay isinitialDelay
which is increased exponentially for subsequent repeats. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
maxRepeats
- Maximum number of allowed repeats, after which the returnedIntFunction
will return a failedCompletable
withRepeatStrategies.TerminateRepeatException
as the cause.initialDelay
- DelayDuration
for the first repeat and increased exponentially with each repeat.maxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff.- Returns:
- An
IntFunction
to be used for repeats which given a repeat count returns aCompletable
that terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithExponentialBackoffDeltaJitter
public static java.util.function.IntFunction<Completable> repeatWithExponentialBackoffDeltaJitter(java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats. For first repeat, the delay isinitialDelay
which is increased exponentially for subsequent repeats.- Parameters:
initialDelay
- DelayDuration
for the first repeat and increased exponentially with each repeat.jitter
- The jitter to apply toinitialDelay
on each repeat.maxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff.- Returns:
- An
IntFunction
to be used for repeats which given a repeat count returns aCompletable
that terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithExponentialBackoffDeltaJitter
public static java.util.function.IntFunction<Completable> repeatWithExponentialBackoffDeltaJitter(int maxRepeats, java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new repeat function that adds a delay between repeats. For first repeat, the delay isinitialDelay
which is increased exponentially for subsequent repeats.- Parameters:
maxRepeats
- Maximum number of allowed repeats, after which the returnedIntFunction
will return a failedCompletable
withRepeatStrategies.TerminateRepeatException
as the cause.initialDelay
- DelayDuration
for the first repeat and increased exponentially with each repeat.jitter
- The jitter to apply toinitialDelay
on each repeat.maxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff.- Returns:
- An
IntFunction
to be used for repeats which given a repeat count returns aCompletable
that terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
-