Class SimpleRetryPolicy

java.lang.Object
io.helidon.config.SimpleRetryPolicy
All Implemented Interfaces:
RetryPolicy, Supplier<RetryPolicy>

public final class SimpleRetryPolicy extends Object implements 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
  • Method Details

    • builder

      public static SimpleRetryPolicy.Builder builder()
      Fluent API builder for SimpleRetryPolicy.
      Returns:
      a new builder
    • create

      public static SimpleRetryPolicy create(Config metaConfig)
      Initializes retry policy instance from configuration properties.

      Mandatory properties, see RetryPolicies.repeat(int):

      • retries - type int
      Optional properties:
      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

      public <T> T execute(Supplier<T> call) throws ConfigException
      Description copied from interface: RetryPolicy
      Invokes the provided Supplier to read the source data and returns that data.

      The implementation of this method incorporates the retry logic.

      Specified by:
      execute in interface RetryPolicy
      Type Parameters:
      T - result type
      Parameters:
      call - supplier of T
      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:

      1. cancel invoked when no invocation of execute is in progress,
      2. cancel invoked when an invocation of execute 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), and
      3. cancel invoked while a load attempt is in progress.
      Specified by:
      cancel in interface RetryPolicy
      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

      public Duration delay()
      Delay between retries.
      Returns:
      delay
    • delayFactor

      public double delayFactor()
      Delay multiplication factor.
      Returns:
      delay factor
    • callTimeout

      public Duration callTimeout()
      Timeout of the call.
      Returns:
      call timeout
    • overallTimeout

      public Duration overallTimeout()
      Overall timeout.
      Returns:
      overall timeout