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

java.lang.Object
io.helidon.faulttolerance.CircuitBreakerConfig.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>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER,PROTOTYPE>
Direct Known Subclasses:
CircuitBreakerConfig.Builder
Enclosing interface:
CircuitBreakerConfig

public abstract static class CircuitBreakerConfig.BuilderBase<BUILDER extends CircuitBreakerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends CircuitBreakerConfig> extends Object implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER,PROTOTYPE>
Fluent API builder base for CircuitBreakerConfig.
  • Constructor Details

    • BuilderBase

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

    • from

      public BUILDER from(CircuitBreakerConfig 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(CircuitBreakerConfig.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

      @Deprecated 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 CircuitBreakerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends CircuitBreakerConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      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 CircuitBreakerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends CircuitBreakerConfig>
      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 of this circuit breaker.
      Parameters:
      name - name
      Returns:
      updated builder instance
      See Also:
    • delay

      public BUILDER delay(Duration delay)
      How long to wait before transitioning from open to half-open state.
      Parameters:
      delay - delay
      Returns:
      updated builder instance
      See Also:
    • errorRatio

      public BUILDER errorRatio(int errorRatio)
      How many failures out of 100 will trigger the circuit to open. This is adapted to the volume() used to handle the window of requests.

      If errorRatio is 40, and volume is 10, 4 failed requests will open the circuit. Default is 60.

      Parameters:
      errorRatio - percent of failure that trigger the circuit to open
      Returns:
      updated builder instance
      See Also:
    • volume

      public BUILDER volume(int volume)
      Rolling window size used to calculate ratio of failed requests. Default is 10.
      Parameters:
      volume - how big a window is used to calculate error errorRatio
      Returns:
      updated builder instance
      See Also:
    • successThreshold

      public BUILDER successThreshold(int successThreshold)
      How many successful calls will close a half-open circuit. Nevertheless, the first failed call will open the circuit again. Default is 1.
      Parameters:
      successThreshold - number of calls
      Returns:
      updated builder instance
      See Also:
    • clearExecutor

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

      public BUILDER executor(ExecutorService executor)
      Executor service to schedule future tasks.
      Parameters:
      executor - executor to use
      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 failures, all other will.
      Parameters:
      skipOn - throwable classes to not be considered a failure
      Returns:
      updated builder instance
      See Also:
    • addSkipOn

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

      public BUILDER addSkipOn(Class<? extends Throwable> skipOn)
      These throwables will not be considered failures, all other will.
      Parameters:
      skipOn - add single throwable classes to not be considered a failure
      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 failures.
      Parameters:
      applyOn - throwable classes to be considered a failure
      Returns:
      updated builder instance
      See Also:
    • addApplyOn

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

      public BUILDER addApplyOn(Class<? extends Throwable> applyOn)
      These throwables will be considered failures.
      Parameters:
      applyOn - add single throwable classes to be considered a failure
      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 of this circuit breaker.
      Returns:
      name
    • delay

      public Duration delay()
      How long to wait before transitioning from open to half-open state.
      Returns:
      delay
    • errorRatio

      public int errorRatio()
      How many failures out of 100 will trigger the circuit to open. This is adapted to the volume() used to handle the window of requests.

      If errorRatio is 40, and volume is 10, 4 failed requests will open the circuit. Default is 60.

      Returns:
      percent of failure that trigger the circuit to open
      See Also:
    • volume

      public int volume()
      Rolling window size used to calculate ratio of failed requests. Default is 10.
      Returns:
      how big a window is used to calculate error errorRatio
      See Also:
    • successThreshold

      public int successThreshold()
      How many successful calls will close a half-open circuit. Nevertheless, the first failed call will open the circuit again. Default is 1.
      Returns:
      number of calls
    • executor

      public Optional<ExecutorService> executor()
      Executor service to schedule future tasks.
      Returns:
      executor to use
    • skipOn

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

      public Set<Class<? extends Throwable>> applyOn()
      These throwables will be considered failures.
      Returns:
      throwable classes to be considered a failure
      See Also:
    • 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