Class CircuitBreakerBuilder

java.lang.Object
com.linecorp.armeria.client.circuitbreaker.CircuitBreakerBuilder

public final class CircuitBreakerBuilder
extends Object
Builds a CircuitBreaker instance using builder pattern.
  • Method Details

    • failureRateThreshold

      public CircuitBreakerBuilder failureRateThreshold​(double failureRateThreshold)
      Sets the threshold of failure rate to detect a remote service fault. Defaults to 0.5 if unspecified.
      Parameters:
      failureRateThreshold - The rate between 0 (exclusive) and 1 (inclusive)
    • minimumRequestThreshold

      public CircuitBreakerBuilder minimumRequestThreshold​(long minimumRequestThreshold)
      Sets the minimum number of requests within a time window necessary to detect a remote service fault. Defaults to 10L if unspecified.
    • trialRequestInterval

      public CircuitBreakerBuilder trialRequestInterval​(Duration trialRequestInterval)
      Sets the trial request interval in HALF_OPEN state. Defaults to 3 seconds if unspecified.
    • trialRequestIntervalMillis

      public CircuitBreakerBuilder trialRequestIntervalMillis​(long trialRequestIntervalMillis)
      Sets the trial request interval in HALF_OPEN state in milliseconds. Defaults to 3 seconds if unspecified.
    • circuitOpenWindow

      public CircuitBreakerBuilder circuitOpenWindow​(Duration circuitOpenWindow)
      Sets the duration of OPEN state. Defaults to 10 seconds if unspecified.
    • circuitOpenWindowMillis

      public CircuitBreakerBuilder circuitOpenWindowMillis​(long circuitOpenWindowMillis)
      Sets the duration of OPEN state in milliseconds. Defaults to 10 seconds if unspecified.
    • counterSlidingWindow

      public CircuitBreakerBuilder counterSlidingWindow​(Duration counterSlidingWindow)
      Sets the time length of sliding window to accumulate the count of events. Defaults to 20 seconds if unspecified.
    • counterSlidingWindowMillis

      public CircuitBreakerBuilder counterSlidingWindowMillis​(long counterSlidingWindowMillis)
      Sets the time length of sliding window to accumulate the count of events, in milliseconds. Defaults to 20 seconds if unspecified.
    • counterUpdateInterval

      public CircuitBreakerBuilder counterUpdateInterval​(Duration counterUpdateInterval)
      Sets the interval that a circuit breaker can see the latest accumulated count of events. Defaults to 1 second if unspecified.
    • counterUpdateIntervalMillis

      public CircuitBreakerBuilder counterUpdateIntervalMillis​(long counterUpdateIntervalMillis)
      Sets the interval that a circuit breaker can see the latest accumulated count of events, in milliseconds. Defaults to 1 second if unspecified.
    • listener

      public CircuitBreakerBuilder listener​(CircuitBreakerListener listener)
    • build

      public CircuitBreaker build()
      Returns a newly-created CircuitBreaker based on the properties of this builder.