CircuitBreakerConfig

data class CircuitBreakerConfig(val failureThreshold: Int = 5, val resetTimeout: Duration = 30.seconds)(source)

Circuit breaker that stops retries when failures exceed a threshold.

Prevents cascading failures by "opening" the circuit after failureThreshold consecutive failures within resetTimeout. While open, requests fail immediately with com.github.ayastrebov.volvo.api.exception.RateLimitException instead of hitting the server.

After resetTimeout elapses, the circuit moves to "half-open" and allows one request through. If it succeeds, the circuit closes. If it fails, it opens again.

VolvoCarsConfig(
apiKey = "your-key",
token = "your-token",
circuitBreaker = CircuitBreakerConfig(
failureThreshold = 5,
resetTimeout = 60.seconds
)
)

Constructors

Link copied to clipboard
constructor(failureThreshold: Int = 5, resetTimeout: Duration = 30.seconds)

Properties

Link copied to clipboard

Number of consecutive failures before opening the circuit (must be > 0)

Link copied to clipboard

Duration to wait before allowing a test request through (must be positive)