- Companion
- class
Type members
Classlikes
Builders specified for CircuitBreaker, using the Partially-Applied Type technique.
Builders specified for CircuitBreaker, using the Partially-Applied Type technique.
The initial State of the CircuitBreaker. While in this state the circuit breaker allows tasks to be executed.
The initial State of the CircuitBreaker. While in this state the circuit breaker allows tasks to be executed.
Contract:
- Exceptions increment the
failures
counter - Successes reset the failure count to zero
- When the
failures
counter reaches themaxFailures
count, the breaker is tripped into theOpen
state
- Value Params
- failures
is the current failures count
State of the CircuitBreaker in which the circuit breaker has already allowed a task to go through, as a reset attempt, in order to test the connection.
State of the CircuitBreaker in which the circuit breaker has already allowed a task to go through, as a reset attempt, in order to test the connection.
Contract:
- The first task when
Open
has expired is allowed through without failing fast, just before the circuit breaker is evolved into theHalfOpen
state - All tasks attempted in
HalfOpen
fail-fast with an exception just as in Open state - If that task attempt succeeds, the breaker is reset back to
the
Closed
state, with theresetTimeout
and thefailures
count also reset to initial values - If the first call fails, the breaker is tripped again into
the
Open
state (theresetTimeout
is multiplied by the exponential backoff factor)
- Value Params
- awaitClose
is a
Deferred
(pure promise) that will get completed when theCircuitBreaker
will switch to theClosed
state again; this reference isNone
in case theF[_]
used does not implementcats.effect.Async
, because only withAsync
data types we can wait for completion.- resetTimeout
is the current
resetTimeout
that was applied to the previousOpen
state, to be multiplied by the exponential backoff factor for the next transition toOpen
, in case the reset attempt fails
- Companion
- object
State of the CircuitBreaker in which the circuit breaker rejects all tasks with an ExecutionRejectedException.
State of the CircuitBreaker in which the circuit breaker rejects all tasks with an ExecutionRejectedException.
Contract:
- all tasks fail fast with
ExecutionRejectedException
- after the configured
resetTimeout
, the circuit breaker enters a HalfOpen state, allowing one task to go through for testing the connection
- Value Params
- awaitClose
is a
Deferred
(pure promise) that will get completed when theCircuitBreaker
will switch to theClosed
state again; this reference isNone
in case theF[_]
used does not implementcats.effect.Async
, because only withAsync
data types we can wait for completion.- resetTimeout
is the current
resetTimeout
that is applied to thisOpen
state, to be multiplied by the exponential backoff factor for the next transition fromHalfOpen
toOpen
, in case the reset attempt fails- startedAt
is the timestamp in milliseconds since the epoch when the transition to
Open
happened
- Companion
- object
An enumeration that models the internal state of CircuitBreaker, kept in an Atomic for synchronization.
An enumeration that models the internal state of CircuitBreaker, kept in an Atomic for synchronization.
The initial state when initializing a CircuitBreaker is Closed. The available states:
Value members
Concrete methods
Builders specified for CircuitBreaker, using the Partially-Applied Type technique.
Builders specified for CircuitBreaker, using the Partially-Applied Type technique.
Example:
import scala.concurrent.duration._
import cats.effect.{IO, Clock}
implicit val clock: Clock[IO] = Clock.create[IO]
val cb = CircuitBreaker[IO].of(
maxFailures = 10,
resetTimeout = 3.second,
exponentialBackoffFactor = 2
)
Safe builder.
Safe builder.
- Value Params
- exponentialBackoffFactor
$exponentialBackoffFactorParam
- maxFailures
$maxFailuresParam
- maxResetTimeout
$maxResetTimeoutParam
- padding
$paddingParam
- resetTimeout
$resetTimeoutParam
- See also
CircuitBreaker[F].of, the version that uses the "partially-applied type technique"
Unsafe builder (that violates referential transparency).
Unsafe builder (that violates referential transparency).
$unsafeWarning
- Value Params
- exponentialBackoffFactor
$exponentialBackoffFactorParam
- maxFailures
$maxFailuresParam
- maxResetTimeout
$maxResetTimeoutParam
- padding
$paddingParam
- resetTimeout
$resetTimeoutParam
- See also
CircuitBreaker[F].unsafe, the version that uses the "partially-applied type technique"