Class RetryConfig.BuilderBase<BUILDER extends RetryConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends RetryConfig>

java.lang.Object
io.helidon.faulttolerance.RetryConfig.BuilderBase<BUILDER, PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER, PROTOTYPE>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Direct Known Subclasses:
RetryConfig.Builder
Enclosing interface:
RetryConfig

public abstract static class RetryConfig.BuilderBase<BUILDER extends RetryConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends RetryConfig> extends Object implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Fluent API builder base for RetryConfig.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Generated implementation of the prototype, can be extended by descendant prototype implementations.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Protected to support extensibility.
  • Method Summary

    Modifier and Type
    Method
    Description
    addApplyOn(Class<? extends Throwable> applyOn)
    These throwables will be considered retriable.
    addApplyOn(Set<Class<? extends Throwable>> applyOn)
    These throwables will be considered retriable.
    addSkipOn(Class<? extends Throwable> skipOn)
    These throwables will not be considered retriable, all other will.
    addSkipOn(Set<Class<? extends Throwable>> skipOn)
    These throwables will not be considered retriable, all other will.
    Set<Class<? extends Throwable>>
    These throwables will be considered retriable.
    applyOn(Set<Class<? extends Throwable>> applyOn)
    These throwables will be considered retriable.
    int
    Number of calls, including the initial call and retries, which must be at least 1.
    calls(int calls)
    Number of calls, including the initial call and retries, which must be at least 1.
    Clear all applyOn.
    Clear existing value of maxDelay.
    Clear existing value of name.
    Clear existing value of retryPolicy.
    Clear all skipOn.
    protected Optional<Config>
    Configuration used to configure this instance.
    config(Config config)
    Update builder from configuration (node of this type).
    Non-negative base delay between the initial call and retries, which defaults to 200 ms.
    delay(Duration delay)
    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.
    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.
    boolean
    Flag to enable metrics for this instance.
    enableMetrics(boolean enableMetrics)
    Flag to enable metrics for this instance.
    from(RetryConfig prototype)
    Update this builder from an existing prototype instance.
    Update this builder from an existing prototype builder 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.
    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.
    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.
    jitterFactor(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.
    Optional non-negative maximum delay applied after jitter; when absent, the delay is not capped.
    maxDelay(Duration maxDelay)
    Optional non-negative maximum delay applied after jitter; when absent, the delay is not capped.
    Name for debugging, error reporting, monitoring.
    name(String name)
    Name for debugging, error reporting, monitoring.
    Positive overall timeout used to bound the complete retry sequence.
    overallTimeout(Duration overallTimeout)
    Positive overall timeout used to bound the complete retry sequence.
    protected void
    Handles providers and decorators.
    Explicitly configured retry policy.
    Explicitly configured retry policy.
    Set<Class<? extends Throwable>>
    These throwables will not be considered retriable, all other will.
    skipOn(Set<Class<? extends Throwable>> skipOn)
    These throwables will not be considered retriable, all other will.
     
    protected void
    Validates required properties.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface Prototype.Builder

    buildPrototype, self
    Modifier and Type
    Method
    Description
    Create an instance of the Prototype.
    default BUILDER
    Instance of this builder as the correct type.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(RetryConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(RetryConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface ConfigBuilderSupport.ConfiguredBuilder<BUILDER extends RetryConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends RetryConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • clearName

      public BUILDER clearName()
      Clear existing value of name.
      Returns:
      updated builder instance
      See Also:
    • name

      public BUILDER name(String name)
      Name for debugging, error reporting, monitoring.
      Parameters:
      name - name of this retry
      Returns:
      updated builder instance
      See Also:
    • calls

      public BUILDER calls(int calls)
      Number of calls, including the initial call and retries, which must be at least 1.
      Parameters:
      calls - number of desired calls, must be 1 (means no retries) or higher.
      Returns:
      updated builder instance
      See Also:
    • delay

      public BUILDER delay(Duration delay)
      Non-negative base delay between the initial call and retries, which defaults to 200 ms.
      Parameters:
      delay - delay between retries (combines with retry policy)
      Returns:
      updated builder instance
      See Also:
    • delayFactor

      public BUILDER 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.
      Parameters:
      delayFactor - delay factor for delaying retry policy
      Returns:
      updated builder instance
      See Also:
    • jitter

      public BUILDER 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.
      Parameters:
      jitter - jitter
      Returns:
      updated builder instance
      See Also:
    • jitterFactor

      public BUILDER jitterFactor(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.
      Parameters:
      jitterFactor - relative jitter factor
      Returns:
      updated builder instance
      See Also:
    • clearMaxDelay

      public BUILDER clearMaxDelay()
      Clear existing value of maxDelay.
      Returns:
      updated builder instance
      See Also:
    • maxDelay

      public BUILDER maxDelay(Duration maxDelay)
      Optional non-negative maximum delay applied after jitter; when absent, the delay is not capped.
      Parameters:
      maxDelay - maximum delay, if configured
      Returns:
      updated builder instance
      See Also:
    • overallTimeout

      public BUILDER overallTimeout(Duration overallTimeout)
      Positive overall timeout used to bound the complete retry sequence.
      Parameters:
      overallTimeout - overall timeout
      Returns:
      updated builder instance
      See Also:
    • clearSkipOn

      public BUILDER clearSkipOn()
      Clear all skipOn.
      Returns:
      updated builder instance
      See Also:
    • skipOn

      public BUILDER skipOn(Set<Class<? extends Throwable>> skipOn)
      These throwables will not be considered retriable, all other will.
      Parameters:
      skipOn - throwable classes to skip retries
      Returns:
      updated builder instance
      See Also:
    • addSkipOn

      public BUILDER addSkipOn(Set<Class<? extends Throwable>> skipOn)
      These throwables will not be considered retriable, all other will.
      Parameters:
      skipOn - throwable classes to skip retries
      Returns:
      updated builder instance
      See Also:
    • addSkipOn

      public BUILDER addSkipOn(Class<? extends Throwable> skipOn)
      These throwables will not be considered retriable, all other will.
      Parameters:
      skipOn - add single throwable classes to skip retries
      Returns:
      updated builder instance
      See Also:
    • clearApplyOn

      public BUILDER clearApplyOn()
      Clear all applyOn.
      Returns:
      updated builder instance
      See Also:
    • applyOn

      public BUILDER applyOn(Set<Class<? extends Throwable>> applyOn)
      These throwables will be considered retriable.
      Parameters:
      applyOn - throwable classes to trigger retries
      Returns:
      updated builder instance
      See Also:
    • addApplyOn

      public BUILDER addApplyOn(Set<Class<? extends Throwable>> applyOn)
      These throwables will be considered retriable.
      Parameters:
      applyOn - throwable classes to trigger retries
      Returns:
      updated builder instance
      See Also:
    • addApplyOn

      public BUILDER addApplyOn(Class<? extends Throwable> applyOn)
      These throwables will be considered retriable.
      Parameters:
      applyOn - add single throwable classes to trigger retries
      Returns:
      updated builder instance
      See Also:
    • clearRetryPolicy

      public BUILDER clearRetryPolicy()
      Clear existing value of retryPolicy.
      Returns:
      updated builder instance
      See Also:
    • retryPolicy

      public BUILDER retryPolicy(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.
      Parameters:
      retryPolicy - retry policy
      Returns:
      updated builder instance
      See Also:
    • enableMetrics

      public BUILDER 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.
      Parameters:
      enableMetrics - metrics enabled flag
      Returns:
      updated builder instance
      See Also:
    • name

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

      public 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

      public 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

      public 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

      public 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

      public 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

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

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

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

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

      public 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

      public 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.
    • config

      protected Optional<Config> config()
      Configuration used to configure this instance.
      Returns:
      config instance