Interface RetryConfig

All Superinterfaces:
Prototype.Api, Prototype.Factory<Retry>
All Known Implementing Classes:
RetryConfig.BuilderBase.RetryConfigImpl

public interface RetryConfig extends Prototype.Api
Retry configuration bean.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Fluent API builder for Retry.
    static class 
    Fluent API builder base for RetryConfig.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default calls to make.
    static final Duration
    Default delay between retries.
    static final Duration
    Default overall timeout.
  • Method Summary

    Modifier and Type
    Method
    Description
    Set<Class<? extends Throwable>>
    These throwables will be considered retriable.
    Create a new fluent API builder to customize configuration.
    builder(RetryConfig instance)
    Create a new fluent API builder from an existing instance.
    int
    Number of calls, including the initial call and retries, which must be at least 1.
    Create a new instance with default values.
    create(Config config)
    Create a new instance from configuration.
    Non-negative base delay between the initial call and retries, which defaults to 200 ms.
    double
    Delay multiplier that must be -1 or finite and non-negative; -1 selects 2 unless either jitter option is configured, and an explicit multiplier is applied before jitter.
    boolean
    Flag to enable metrics for this instance.
    Absolute random jitter that must be PT-1S (disabled) or non-negative; it cannot be combined with jitter-factor, is applied independently after delay-factor, does not affect later base-delay calculations, and is capped by max-delay when present.
    default double
    Relative random jitter that must be -1 (disabled) or from 0 (inclusive) to 1 (exclusive); it cannot be combined with jitter, is applied independently after delay-factor, does not affect later base-delay calculations, and is capped by max-delay when present.
    Optional non-negative maximum delay applied after jitter; when absent, the delay is not capped.
    Name for debugging, error reporting, monitoring.
    Positive overall timeout used to bound the complete retry sequence.
    Explicitly configured retry policy.
    Set<Class<? extends Throwable>>
    These throwables will not be considered retriable, all other will.

    Methods inherited from interface Prototype.Factory

    build
    Modifier and Type
    Method
    Description
    Create a new instance of the runtime type from this config object.
  • Field Details

    • DEFAULT_CALLS

      static final int DEFAULT_CALLS
      Default calls to make.
      See Also:
    • DEFAULT_DELAY

      static final Duration DEFAULT_DELAY
      Default delay between retries.
      See Also:
    • DEFAULT_OVERALL_TIMEOUT

      static final Duration DEFAULT_OVERALL_TIMEOUT
      Default overall timeout.
      See Also:
  • Method Details

    • builder

      static RetryConfig.Builder builder()
      Create a new fluent API builder to customize configuration.
      Returns:
      a new builder
    • builder

      static RetryConfig.Builder builder(RetryConfig instance)
      Create a new fluent API builder from an existing instance.
      Parameters:
      instance - an existing instance used as a base for the builder
      Returns:
      a builder based on an instance
    • create

      static RetryConfig create(Config config)
      Create a new instance from configuration.
      Parameters:
      config - used to configure the new instance
      Returns:
      a new instance configured from configuration
    • create

      static RetryConfig create()
      Create a new instance with default values.
      Returns:
      a new instance
    • name

      Optional<String> name()
      Name for debugging, error reporting, monitoring.
      Returns:
      name of this retry
    • calls

      int calls()
      Number of calls, including the initial call and retries, which must be at least 1.
      Returns:
      number of desired calls, must be 1 (means no retries) or higher.
    • delay

      Duration delay()
      Non-negative base delay between the initial call and retries, which defaults to 200 ms.
      Returns:
      delay between retries (combines with retry policy)
    • delayFactor

      double delayFactor()
      Delay multiplier that must be -1 or finite and non-negative; -1 selects 2 unless either jitter option is configured, and an explicit multiplier is applied before jitter.
      Returns:
      delay factor for delaying retry policy
    • jitter

      Duration jitter()
      Absolute random jitter that must be PT-1S (disabled) or non-negative; it cannot be combined with jitter-factor, is applied independently after delay-factor, does not affect later base-delay calculations, and is capped by max-delay when present.
      Returns:
      jitter
    • jitterFactor

      default double jitterFactor()
      Relative random jitter that must be -1 (disabled) or from 0 (inclusive) to 1 (exclusive); it cannot be combined with jitter, is applied independently after delay-factor, does not affect later base-delay calculations, and is capped by max-delay when present. A value of 0.2 applies a random jitter of up to twenty percent in either direction.
      Returns:
      relative jitter factor
    • maxDelay

      default Optional<Duration> maxDelay()
      Optional non-negative maximum delay applied after jitter; when absent, the delay is not capped.
      Returns:
      maximum delay, if configured
    • overallTimeout

      Duration overallTimeout()
      Positive overall timeout used to bound the complete retry sequence.
      Returns:
      overall timeout
    • skipOn

      Set<Class<? extends Throwable>> skipOn()
      These throwables will not be considered retriable, all other will.
      Returns:
      throwable classes to skip retries
      See Also:
    • applyOn

      Set<Class<? extends Throwable>> applyOn()
      These throwables will be considered retriable.
      Returns:
      throwable classes to trigger retries
      See Also:
    • retryPolicy

      Optional<Retry.RetryPolicy> retryPolicy()
      Explicitly configured retry policy. The most recently configured policy-related option takes precedence. Configuring calls, delay, delay factor, jitter, jitter factor, or maximum delay after this option clears it so a new policy is derived from those settings.
      Returns:
      retry policy
    • enableMetrics

      boolean enableMetrics()
      Flag to enable metrics for this instance. The value of this flag is combined with the global config entry FaultTolerance.FT_METRICS_DEFAULT_ENABLED. If either of these flags is true, then metrics will be enabled for the instance.
      Returns:
      metrics enabled flag