Package io.atlassian.fugue.retry
Class RetryFunction<F,T>
java.lang.Object
io.atlassian.fugue.retry.RetryFunction<F,T>
- Type Parameters:
F- The type of the parameter the Function acceptsT- The type of the result the Function yields upon application
- All Implemented Interfaces:
Function<F,T>
A Function which wraps the apply method of another Function and attempts it
up to a fixed number of times. This class can be used when a task is known to
be prone to occasional failure and other workarounds are not known.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Runnableprivate final ExceptionHandlerprivate final int -
Constructor Summary
ConstructorsConstructorDescriptionRetryFunction(Function<F, T> function, int tries) An instance that does nothing before retrying and ignores exceptions that occur.RetryFunction(Function<F, T> function, int tries, ExceptionHandler handler) An instance that does nothing before retrying.RetryFunction(Function<F, T> function, int tries, ExceptionHandler handler, Runnable beforeRetry) Constructor for RetryFunction. -
Method Summary
-
Field Details
-
function
-
tries
private final int tries -
handler
-
beforeRetry
-
-
Constructor Details
-
RetryFunction
An instance that does nothing before retrying and ignores exceptions that occur.- Parameters:
function- which fetches the result, must not be nulltries- the numbe rof times to attempt to get a result, must be positive
-
RetryFunction
An instance that does nothing before retrying.- Parameters:
function- which fetches the result, must not be nulltries- the number of times to attempt to get a result, must be positivehandler- reacts to exceptions thrown by the supplier, must not be null
-
RetryFunction
public RetryFunction(Function<F, T> function, int tries, ExceptionHandler handler, Runnable beforeRetry) Constructor for RetryFunction.
- Parameters:
function- which fetches the result, must not be nulltries- the number of times to attempt to get a result, must be positivehandler- reacts to exceptions thrown by the supplier, must not be nullbeforeRetry- an effect that is run before a retry attempt
-
-
Method Details
-
apply
Attempt to apply parameter to the wrapped Function tries number of times. Any exceptions thrown will be ignored until the number of attempts is reached. If the number of attempts is reached without a successful result, the most recent exception to be thrown will be rethrown.
-