java.lang.Object
io.helidon.config.SimpleRetryPolicy
- All Implemented Interfaces:
RetryPolicy
,Supplier<RetryPolicy>
A default retry policy implementation with
ScheduledExecutorService
.
Following attributes can be configured:
- number of retries (excluding the first invocation)
- delay between the invocations
- a delay multiplication factor
- a timeout for the individual invocation
- an overall timeout
- an executor service
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleRetryPolicy.Builder
builder()
Fluent API builder forSimpleRetryPolicy
.Timeout of the call.boolean
cancel
(boolean mayInterruptIfRunning) Cancels the current use of the retry policy.static SimpleRetryPolicy
Initializes retry policy instance from configuration properties.delay()
Delay between retries.double
Delay multiplication factor.<T> T
Invokes the providedSupplier
to read the source data and returns that data.Overall timeout.int
retries()
Number of retries.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.config.spi.RetryPolicy
get
-
Method Details
-
builder
Fluent API builder forSimpleRetryPolicy
.- Returns:
- a new builder
-
create
Initializes retry policy instance from configuration properties.Mandatory
properties
, seeRetryPolicies.repeat(int)
:retries
- typeint
properties
:delay
- typeDuration
, seeSimpleRetryPolicy.Builder.delay(Duration)
delay-factor
- typedouble
, seeSimpleRetryPolicy.Builder.delayFactor(double)
call-timeout
- typeDuration
, seeSimpleRetryPolicy.Builder.callTimeout(Duration)
overall-timeout
- typeDuration
, seeSimpleRetryPolicy.Builder.overallTimeout(Duration)
- Parameters:
metaConfig
- meta-configuration used to initialize returned polling strategy builder instance from.- Returns:
- new instance of polling strategy builder described by
metaConfig
- Throws:
MissingValueException
- in case the configuration tree does not contain all expected sub-nodes required by the mapper implementation to provide instance of Java type.ConfigMappingException
- in case the mapper fails to map the (existing) configuration tree represented by the supplied configuration node to an instance of a given Java type.- See Also:
-
execute
Description copied from interface:RetryPolicy
Invokes the providedSupplier
to read the source data and returns that data.The implementation of this method incorporates the retry logic.
- Specified by:
execute
in interfaceRetryPolicy
- Type Parameters:
T
- result type- Parameters:
call
- supplier ofT
- Returns:
- loaded data returned by the provided
Supplier
- Throws:
ConfigException
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) Description copied from interface:RetryPolicy
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.
- Specified by:
cancel
in interfaceRetryPolicy
- 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
-
retries
public int retries()Number of retries.- Returns:
- retries
-
delay
Delay between retries.- Returns:
- delay
-
delayFactor
public double delayFactor()Delay multiplication factor.- Returns:
- delay factor
-
callTimeout
Timeout of the call.- Returns:
- call timeout
-
overallTimeout
Overall timeout.- Returns:
- overall timeout
-