Package ratpack.exec.util.retry
Class AttemptRetryPolicy
- java.lang.Object
-
- ratpack.exec.util.retry.AttemptRetryPolicy
-
- All Implemented Interfaces:
RetryPolicy
public final class AttemptRetryPolicy extends Object implements RetryPolicy
An attempt based implementation ofRetryPolicy
.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.
- Since:
- 1.7
- See Also:
AttemptRetryPolicyBuilder
-
-
Constructor Summary
Constructors Constructor Description AttemptRetryPolicy(Delay delay, int maxAttempts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
attempts()
Attempts performed so far.Promise<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.
-
-
-
Constructor Detail
-
AttemptRetryPolicy
public AttemptRetryPolicy(Delay delay, int maxAttempts)
-
-
Method Detail
-
of
public static AttemptRetryPolicy of(Action<? super AttemptRetryPolicyBuilder> definition) throws Exception
Builds a new attempt based retry policy from the given definition.- Parameters:
definition
- the attempt based retry policy definition- Returns:
- an attempt based retry policy
- Throws:
Exception
- any thrown by building the attempt based retry policy
-
isExhausted
public boolean isExhausted()
If the caller should stop retrying.- Specified by:
isExhausted
in interfaceRetryPolicy
- Returns:
- TRUE if the caller should stop retrying
-
attempts
public int attempts()
Attempts performed so far. Starts on 1, i.e. when no retry has been performed yet this returns 1.- Specified by:
attempts
in interfaceRetryPolicy
- Returns:
- attempts performed so far.
-
delay
public Promise<Duration> delay()
Promise that returns the waiting time before retrying.- Specified by:
delay
in interfaceRetryPolicy
- Returns:
- promise that returns the waiting time before retrying
- See Also:
and its implementors for different strategies
-
increaseAttempt
public RetryPolicy increaseAttempt()
Increase number of attempts.- Specified by:
increaseAttempt
in interfaceRetryPolicy
- Returns:
- this policy after updating the internal state around attempts
-
-