@FunctionalInterface public interface RetryPolicy
Policies decide if a retry should be performed or not by expiring after some given parameters.
Policies are factories, and do not maintain any state in themselves. They can be safely re-used like this:
public class Main {
public static final RetryPolicy LINEAR =
timed(10, TimeUnit.SECONDS, linear(10, TimeUnit.MILLISECONDS))
}
Modifier and Type | Interface and Description |
---|---|
static class |
RetryPolicy.Exponential
Implementation for the exponential retry policy.
|
static class |
RetryPolicy.ExponentialBuilder
Builder of exponential retry policies.
|
static class |
RetryPolicy.Linear
Implementation for the linear retry policy.
|
static class |
RetryPolicy.Timed
Implementation for the timed retry policy.
|
Modifier and Type | Method and Description |
---|---|
static RetryPolicy.ExponentialBuilder |
exponential(long duration,
TimeUnit unit)
Setup an exponential backoff retry policy.
|
static RetryPolicy |
linear(long duration,
TimeUnit unit)
Build a linear retry policy.
|
Supplier<RetryDecision> |
newInstance(ClockSource clockSource)
Create a new instance of the policy.
|
static RetryPolicy |
timed(long duration,
TimeUnit unit,
RetryPolicy policy)
Wrap an existing retry policy which is only valid for a given time.
|
Supplier<RetryDecision> newInstance(ClockSource clockSource)
the provided instance may only be used by one thread at a time
clockSource
- clock source to use in the instancestatic RetryPolicy linear(long duration, TimeUnit unit)
duration
- linear backoff to as a duration to applyunit
- unit of durationstatic RetryPolicy.ExponentialBuilder exponential(long duration, TimeUnit unit)
duration
- the base time to backoff in millisecondsunit
- unit of durationstatic RetryPolicy timed(long duration, TimeUnit unit, RetryPolicy policy)
This allows you to provide a custom clock source.
duration
- the duration for which the policy should be validunit
- time unit of the durationpolicy
- the policy to wrapCopyright © 2017. All rights reserved.