-
- All Superinterfaces:
Supplier<RetryPolicy>
- All Known Implementing Classes:
SimpleRetryPolicy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface RetryPolicy extends Supplier<RetryPolicy>
Mechanism for controlling retry of attempts to load data by aConfigSource
.When a
Config
attempts to load the underlying data of aConfigSource
it uses aRetryPolicy
to govern if and how it retries the load operation in case of errors.The
execute(java.util.function.Supplier)
method of each policy implementation must perform at least one attempt to load the data, even if it chooses not to retry in case of errors.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
cancel(boolean mayInterruptIfRunning)
Cancels the current use of the retry policy.<T> T
execute(Supplier<T> call)
Invokes the providedSupplier
to read the source data and returns that data.default RetryPolicy
get()
-
-
-
Method Detail
-
execute
<T> T execute(Supplier<T> call)
Invokes the providedSupplier
to read the source data and returns that data.The implementation of this method incorporates the retry logic.
- Type Parameters:
T
- result type- Parameters:
call
- supplier ofT
- Returns:
- loaded data returned by the provided
Supplier
-
cancel
default boolean cancel(boolean mayInterruptIfRunning)
Cancels the current use of the retry policy.Implementations should correctly handle three cases:
cancel
invoked when no invocation ofexecute
is in progress,cancel
invoked when an invocation ofexecute
is active but no attempted load is actually in progress (e.g., a prior attempt failed and the retry policy is waiting for some time to pass before trying again), andcancel
invoked while a load attempt is in progress.
- Parameters:
mayInterruptIfRunning
- whether an in-progress load attempt should be interrupted- Returns:
false
if the task could not be canceled, typically because it has already completed;true
otherwise
-
get
default RetryPolicy get()
- Specified by:
get
in interfaceSupplier<RetryPolicy>
-
-