circuitBreakerPolicy

fun circuitBreakerPolicy(scope: ResilientScope, failureThreshold: Int = 3, successThreshold: Int = 2, timeout: Duration = 5.seconds): ResilientPolicy

Creates a ResilientPolicy with a circuit breaker configured for fast testing.

Default configuration:

  • failureThreshold = 3

  • successThreshold = 2

  • halfOpenMaxCalls = 1

  • timeout = 5.seconds

Return

A configured ResilientPolicy with circuit breaker.

Parameters

scope

The ResilientScope for the policy.

failureThreshold

Number of failures to open the circuit. Default is 3.

successThreshold

Number of successes to close the circuit from half-open. Default is 2.

timeout

Duration the circuit stays open. Default is 5 seconds.