Interface CircuitBreaker

All Superinterfaces:
FtHandler, RuntimeType.Api<io.helidon.faulttolerance.CircuitBreakerConfig>

@Contract public interface CircuitBreaker extends FtHandler, RuntimeType.Api<io.helidon.faulttolerance.CircuitBreakerConfig>
CircuitBreaker protects a potentially failing endpoint from overloading and the application from spending resources on those endpoints.

In case too many errors are detected, the circuit opens and all new requests fail with a CircuitBreakerOpenException for a period of time. After this period, attempts are made to check if the service is up again - if so, the circuit closes and requests can process as usual again.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    A circuit breaker can be in any of 3 possible states as defined by this enum.
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.helidon.faulttolerance.CircuitBreakerConfig.Builder
    A new circuit breaker fluent API builder.
    create(io.helidon.faulttolerance.CircuitBreakerConfig config)
    Create a new circuit builder based on its configuration.
    create(Consumer<io.helidon.faulttolerance.CircuitBreakerConfig.Builder> builderConsumer)
    Create a new circuit breaker with a possibility to customize its configuration.
    Current breaker state.
    void
    Set state of this circuit breaker.

    Methods inherited from interface io.helidon.faulttolerance.FtHandler

    invoke, name

    Methods inherited from interface io.helidon.builder.api.RuntimeType.Api

    prototype
  • Method Details

    • create

      static CircuitBreaker create(io.helidon.faulttolerance.CircuitBreakerConfig config)
      Create a new circuit builder based on its configuration.
      Parameters:
      config - circuit breaker configuration
      Returns:
      a new circuit breaker
    • create

      static CircuitBreaker create(Consumer<io.helidon.faulttolerance.CircuitBreakerConfig.Builder> builderConsumer)
      Create a new circuit breaker with a possibility to customize its configuration.
      Parameters:
      builderConsumer - consumer of configuration
      Returns:
      a new circuit breaker
    • builder

      static io.helidon.faulttolerance.CircuitBreakerConfig.Builder builder()
      A new circuit breaker fluent API builder.
      Returns:
      a new builder
    • state

      Current breaker state. As the state may change within nanoseconds, this is for information only.
      Returns:
      current breaker state
    • state

      void state(CircuitBreaker.State newState)
      Set state of this circuit breaker. Note that all usual processes to re-close or open the circuit are in progress. So a subsequent call to state() may yield a different state than configured here
      Parameters:
      newState - state to configure