Class RetryFactory
java.lang.Object
io.atlassian.fugue.retry.RetryFactory
Provides factory methods for RetryFunction, RetryTask, and RetrySupplier.
These classes can be used when a task is known to fail on occasion and no
other workaround is known.
This class is not instantiable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RunnableDecorates a runnable so that it retries a number of times before being allowed to fail.static Runnablecreate(Runnable task, int tries, ExceptionHandler handler) Decorates a runnable so that it retries a number of times before being allowed to fail.static Runnablecreate(Runnable task, int tries, ExceptionHandler handler, long backoff) Decorates a runnable so that it retries a number of times before being allowed to fail, backing off exponentially in time.static <A,B> Function <A, B> Decorates a function so that it retries a number of times before being allowed to fail.static <A,B> Function <A, B> create(Function<A, B> function, int tries, ExceptionHandler handler) Decorates a function so that it retries a number of times before being allowed to fail.static <A,B> Function <A, B> create(Function<A, B> function, int tries, ExceptionHandler handler, long backoff) Decorates a function so that it retries a number of times before being allowed to fail.static <A> Supplier<A> Decorates a supplier so that it retries a number of times before being allowed to fail.static <A> Supplier<A> create(Supplier<A> supplier, int tries, ExceptionHandler handler) Decorates a supplier so that it retries a number of times before being allowed to fail.static <A> Supplier<A> create(Supplier<A> supplier, int tries, ExceptionHandler handler, long backoff) Decorates a supplier so that it retries a number of times before being allowed to fail, backing-off in time exponentially.
-
Constructor Details
-
RetryFactory
private RetryFactory()
-
-
Method Details
-
create
Decorates a runnable so that it retries a number of times before being allowed to fail.- Parameters:
task- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the call- Returns:
- a runnable which can be used to call another runnable multiple times when that runnable may fail sporadically
-
create
Decorates a runnable so that it retries a number of times before being allowed to fail.- Parameters:
task- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- passed any exceptions that are encountered- Returns:
- a runnable which can be used to call another runnable multiple times when that runnable may fail sporadically
-
create
Decorates a runnable so that it retries a number of times before being allowed to fail, backing off exponentially in time.- Parameters:
task- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplierbackoff- time to wait in millis each time- Returns:
- a runnable which can be used to call another runnable multiple times when that runnable may fail sporadically
-
create
Decorates a supplier so that it retries a number of times before being allowed to fail.- Type Parameters:
A- The type of the object returned by supplier- Parameters:
supplier- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the call- Returns:
- a supplier which can be used to call another supplier multiple times when that supplier may fail sporadically
-
create
Decorates a supplier so that it retries a number of times before being allowed to fail.- Type Parameters:
A- The type of the object returned by supplier- Parameters:
supplier- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplier- Returns:
- a supplier which can be used to call another supplier multiple times when that supplier may fail sporadically
-
create
public static <A> Supplier<A> create(Supplier<A> supplier, int tries, ExceptionHandler handler, long backoff) Decorates a supplier so that it retries a number of times before being allowed to fail, backing-off in time exponentially.- Type Parameters:
A- The type of the object returned by supplier- Parameters:
supplier- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplierbackoff- time to wait in millis each time- Returns:
- a supplier which can be used to call another supplier multiple times when that supplier may fail sporadically
-
create
Decorates a function so that it retries a number of times before being allowed to fail.- Type Parameters:
A- the type of the parameter the function acceptsB- the type of the result of the function's apply method- Parameters:
function- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the call- Returns:
- a function which can be used to invoke another function multiple times when that function may fail sporadically
-
create
public static <A,B> Function<A,B> create(Function<A, B> function, int tries, ExceptionHandler handler) Decorates a function so that it retries a number of times before being allowed to fail.- Type Parameters:
A- the type of the parameter the function acceptsB- the type of the result of the function's apply method- Parameters:
function- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplier- Returns:
- a function which can be used to invoke another function multiple times when that function may fail sporadically
-
create
public static <A,B> Function<A,B> create(Function<A, B> function, int tries, ExceptionHandler handler, long backoff) Decorates a function so that it retries a number of times before being allowed to fail.- Type Parameters:
A- the type of the parameter the function acceptsB- the type of the result of the function's apply method- Parameters:
function- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplierbackoff- time to wait in millis each time- Returns:
- a function which can be used to invoke another function multiple times when that function may fail sporadically
-