CircuitBreakerPluginConfigBuilder

Constructors

Link copied to clipboard
constructor(baseConfig: CircuitBreakerPluginConfig)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Configures the rate in percentage (e.g., 0.5 for 50%) of calls recorded as failure that will trigger the circuit breaker to transition to the Open state, if equalled or exceeded.

Link copied to clipboard

Configures the maximum duration the circuit breaker will wait in the HalfOpen state before transitioning to the Open state automatically. If set to Duration.ZERO, the circuit breaker will wait indefinitely in the HalfOpen state until permittedNumberOfCallsInHalfOpenState is reached.

Link copied to clipboard

Configures the number of calls that are allowed to be made in the HalfOpen state. If this number is exceeded, further calls will be rejected. If maxWaitDurationInHalfOpenState is set to Duration.ZERO, the circuit breaker will wait indefinitely in the HalfOpen state until the permitted number of calls is reached.

Functions

Link copied to clipboard
open override fun build(): CircuitBreakerPluginConfig
Link copied to clipboard

Configures the circuit breaker delay strategy to use a constant delay between transitions from Open to HalfOpen.

Link copied to clipboard
fun customDelayInOpenState(delayStrategyInOpenState: DelayStrategy)

Configures the circuit breaker delay strategy to use a custom delay between transitions from Open to HalfOpen, based on the current attempt and additional context. The attempt is the number of times the circuit breaker transitioned from Open to HalfOpen.

Link copied to clipboard

Configures the circuit breaker delay strategy to use a custom delay provider between transitions from Open to HalfOpen. In contrast to customDelayInOpenState, this method enables caller control over the delay provider (which is the kotlinx.coroutines.delay by default) and optional additional state between transitions. See DelayProvider for more information.

Link copied to clipboard
fun exponentialDelayInOpenState(initialDelay: Duration = 500L.milliseconds, multiplier: Double = 2.0, maxDelay: Duration = 1.minutes)

Configures the circuit breaker delay strategy to use an exponential backoff algorithm to calculate the next delay duration between transitions from Open to HalfOpen. The algorithm is based on the formula:

Link copied to clipboard
fun linearDelayInOpenState(initialDelay: Duration = 500L.milliseconds, multiplier: Double = 1.0, maxDelay: Duration = 1.minutes)

Configures the circuit breaker delay strategy to use a linear backoff algorithm to calculate the next delay duration between transitions from Open to HalfOpen.

Link copied to clipboard

Configures the circuit breaker delay strategy to use no delay between transitions from Open to HalfOpen.

Link copied to clipboard

Configures a predicate to record the response of a call. The predicate should return true if the response is to be considered a failure; false otherwise.

Link copied to clipboard

Determines whether to record as failure the server responses with status codes in the range of 500..599.

Link copied to clipboard
fun slidingWindow(size: Int, minimumThroughput: Int = 100, type: SlidingWindowType = COUNT_BASED)

Configures the sliding window used to record calls and calculate the failure rate.