public final class AttemptRetryPolicy extends java.lang.Object implements RetryPolicy
RetryPolicy
.
This strategy will signal end of retries when the configurable max of retry attempts is surpassed, 5 by default. That number doesn't include the initial request, meaning it will give up after 6 calls, but only 5 retries.
AttemptRetryPolicyBuilder
Constructor and Description |
---|
AttemptRetryPolicy(Delay delay,
int maxAttempts) |
Modifier and Type | Method and Description |
---|---|
int |
attempts()
Attempts performed so far.
|
Promise<java.time.Duration> |
delay()
Promise that returns the waiting time before retrying.
|
RetryPolicy |
increaseAttempt()
Increase number of attempts.
|
boolean |
isExhausted()
If the caller should stop retrying.
|
static AttemptRetryPolicy |
of(Action<? super AttemptRetryPolicyBuilder> definition)
Builds a new attempt based retry policy from the given definition.
|
public AttemptRetryPolicy(Delay delay, int maxAttempts)
public static AttemptRetryPolicy of(Action<? super AttemptRetryPolicyBuilder> definition) throws java.lang.Exception
definition
- the attempt based retry policy definitionjava.lang.Exception
- any thrown by building the attempt based retry policypublic boolean isExhausted()
isExhausted
in interface RetryPolicy
public int attempts()
attempts
in interface RetryPolicy
public Promise<java.time.Duration> delay()
delay
in interface RetryPolicy
and its implementors for different strategies
public RetryPolicy increaseAttempt()
increaseAttempt
in interface RetryPolicy