Package io.servicetalk.concurrent.api
Class RepeatStrategies
java.lang.Object
io.servicetalk.concurrent.api.RepeatStrategies
A set of strategies to use for repeating with
Publisher.repeatWhen(IntFunction),
Single.repeatWhen(IntFunction) and Completable.repeatWhen(IntFunction) or in general.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAnExceptioninstance used to indicate termination of repeats. -
Method Summary
Modifier and TypeMethodDescriptionstatic IntFunction<Completable>repeatWithConstantBackoffDeltaJitter(int maxRepeats, Duration delay, Duration jitter, Executor timerExecutor) Creates a new repeat function that adds the passed constantDurationas delay between repeats.static IntFunction<Completable>repeatWithConstantBackoffDeltaJitter(Duration delay, Duration jitter, Executor timerExecutor) Creates a new repeat function that adds the passed constantDurationas delay between repeats.static IntFunction<Completable>repeatWithConstantBackoffFullJitter(int maxRepeats, Duration delay, Executor timerExecutor) Creates a new repeat function that adds the passed constantDurationas delay between repeats.static IntFunction<Completable>repeatWithConstantBackoffFullJitter(Duration delay, Executor timerExecutor) Creates a new repeat function that adds the passed constantDurationas delay between repeats.static IntFunction<Completable>repeatWithExponentialBackoffDeltaJitter(int maxRepeats, Duration initialDelay, Duration jitter, Duration maxDelay, Executor timerExecutor) Creates a new repeat function that adds a delay between repeats.static IntFunction<Completable>repeatWithExponentialBackoffDeltaJitter(Duration initialDelay, Duration jitter, Duration maxDelay, Executor timerExecutor) Creates a new repeat function that adds a delay between repeats.static IntFunction<Completable>repeatWithExponentialBackoffFullJitter(int maxRepeats, Duration initialDelay, Duration maxDelay, Executor timerExecutor) Creates a new repeat function that adds a delay between repeats.static IntFunction<Completable>repeatWithExponentialBackoffFullJitter(Duration initialDelay, Duration maxDelay, Executor timerExecutor) Creates a new repeat function that adds a delay between repeats.
-
Method Details
-
repeatWithConstantBackoffFullJitter
public static IntFunction<Completable> repeatWithConstantBackoffFullJitter(Duration delay, Executor timerExecutor) Creates a new repeat function that adds the passed constantDurationas delay between repeats.- Parameters:
delay- ConstantDurationof delay between repeats.timerExecutor-Executorto be used to schedule timers for delay.- Returns:
- An
IntFunctionto be used for repeats which given a repeat count returns aCompletablethat terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithConstantBackoffFullJitter
public static IntFunction<Completable> repeatWithConstantBackoffFullJitter(int maxRepeats, Duration delay, Executor timerExecutor) Creates a new repeat function that adds the passed constantDurationas delay between repeats.- Parameters:
maxRepeats- Maximum number of allowed repeats, after which the returnedIntFunctionwill return a failedCompletablewithRepeatStrategies.TerminateRepeatExceptionas the cause.delay- ConstantDurationof delay between repeats.timerExecutor-Executorto be used to schedule timers for delay.- Returns:
- An
IntFunctionto be used for repeats which given a repeat count returns aCompletablethat terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithConstantBackoffDeltaJitter
public static IntFunction<Completable> repeatWithConstantBackoffDeltaJitter(Duration delay, Duration jitter, Executor timerExecutor) Creates a new repeat function that adds the passed constantDurationas delay between repeats.- Parameters:
delay- ConstantDurationof delay between repeats.jitter- The jitter to apply todelayon each repeat.timerExecutor-Executorto be used to schedule timers for delay.- Returns:
- An
IntFunctionto be used for repeats which given a repeat count returns aCompletablethat terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithConstantBackoffDeltaJitter
public static IntFunction<Completable> repeatWithConstantBackoffDeltaJitter(int maxRepeats, Duration delay, Duration jitter, Executor timerExecutor) Creates a new repeat function that adds the passed constantDurationas delay between repeats.- Parameters:
maxRepeats- Maximum number of allowed repeats, after which the returnedIntFunctionwill return a failedCompletablewithRepeatStrategies.TerminateRepeatExceptionas the cause.delay- ConstantDurationof delay between repeats.jitter- The jitter to apply todelayon each repeat.timerExecutor-Executorto be used to schedule timers for delay.- Returns:
- An
IntFunctionto be used for repeats which given a repeat count returns aCompletablethat terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithExponentialBackoffFullJitter
public static IntFunction<Completable> repeatWithExponentialBackoffFullJitter(Duration initialDelay, Duration maxDelay, Executor timerExecutor) Creates a new repeat function that adds a delay between repeats. For first repeat, the delay isinitialDelaywhich is increased exponentially for subsequent repeats. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
initialDelay- DelayDurationfor the first repeat and increased exponentially with each repeat.maxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff.- Returns:
- An
IntFunctionto be used for repeats which given a repeat count returns aCompletablethat terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithExponentialBackoffFullJitter
public static IntFunction<Completable> repeatWithExponentialBackoffFullJitter(int maxRepeats, Duration initialDelay, Duration maxDelay, Executor timerExecutor) Creates a new repeat function that adds a delay between repeats. For first repeat, the delay isinitialDelaywhich 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 returnedIntFunctionwill return a failedCompletablewithRepeatStrategies.TerminateRepeatExceptionas the cause.initialDelay- DelayDurationfor the first repeat and increased exponentially with each repeat.maxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff.- Returns:
- An
IntFunctionto be used for repeats which given a repeat count returns aCompletablethat terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithExponentialBackoffDeltaJitter
public static IntFunction<Completable> repeatWithExponentialBackoffDeltaJitter(Duration initialDelay, Duration jitter, Duration maxDelay, Executor timerExecutor) Creates a new repeat function that adds a delay between repeats. For first repeat, the delay isinitialDelaywhich is increased exponentially for subsequent repeats.- Parameters:
initialDelay- DelayDurationfor the first repeat and increased exponentially with each repeat.jitter- The jitter to apply toinitialDelayon each repeat.maxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff.- Returns:
- An
IntFunctionto be used for repeats which given a repeat count returns aCompletablethat terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-
repeatWithExponentialBackoffDeltaJitter
public static IntFunction<Completable> repeatWithExponentialBackoffDeltaJitter(int maxRepeats, Duration initialDelay, Duration jitter, Duration maxDelay, Executor timerExecutor) Creates a new repeat function that adds a delay between repeats. For first repeat, the delay isinitialDelaywhich is increased exponentially for subsequent repeats.- Parameters:
maxRepeats- Maximum number of allowed repeats, after which the returnedIntFunctionwill return a failedCompletablewithRepeatStrategies.TerminateRepeatExceptionas the cause.initialDelay- DelayDurationfor the first repeat and increased exponentially with each repeat.jitter- The jitter to apply toinitialDelayon each repeat.maxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff.- Returns:
- An
IntFunctionto be used for repeats which given a repeat count returns aCompletablethat terminates successfully when the source has to be repeated or terminates with error if the source should not be repeated.
-