getOrCreate

fun getOrCreate(name: String, configure: CircuitBreakerConfig.() -> Unit, onStateChanged: (CircuitState, CircuitState) -> Unit? = null): DefaultCircuitBreaker

Returns an existing DefaultCircuitBreaker for name, or creates one with configure.

Parameters

name

Unique key for this circuit breaker (e.g. "payments", "db").

configure

Lambda applied to CircuitBreakerConfig only when the instance is created. Ignored on subsequent calls for the same name.

onStateChanged

Optional callback forwarded to DefaultCircuitBreaker only when the instance is created. Receives (newState, oldState). See the class-level telemetry limitation note above.