Builders specified for CircuitBreaker, using the Partially-Applied Type technique.
The initial State of the CircuitBreaker.
The initial State of the CircuitBreaker. While in this state the circuit breaker allows tasks to be executed.
Contract:
failures
counterfailures
counter reaches the maxFailures
count,
the breaker is tripped into the Open
state
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:
Open
has expired is allowed through
without failing fast, just before the circuit breaker is
evolved into the HalfOpen
stateHalfOpen
fail-fast with an exception
just as in Open stateClosed
state, with the resetTimeout
and the
failures
count also reset to initial valuesOpen
state (the resetTimeout
is multiplied by the
exponential backoff factor)
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:
ExecutionRejectedException
resetTimeout
, the circuit breaker
enters a HalfOpen state, allowing one task to go through
for testing the connection
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:
Type-alias to document timestamps specified in milliseconds, as returned by Scheduler.clockRealTime.
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.create[IO] val cb = CircuitBreaker[IO].of( maxFailures = 10, resetTimeout = 3.second, exponentialBackoffFactor = 2 )
Safe builder.
Safe builder.
is the maximum count for failures before opening the circuit breaker
is the timeout to wait in the Open
state
before attempting a close of the circuit breaker (but without
the backoff factor applied)
is a factor to use for resetting
the resetTimeout
when in the HalfOpen
state, in case
the attempt to Close
fails
is the maximum timeout the circuit breaker
is allowed to use when applying the exponentialBackoffFactor
is the PaddingStrategy to apply to the underlying atomic reference used, to use in case contention and "false sharing" become a problem
CircuitBreaker[F].of, the version that uses the "partially-applied type technique"
Unsafe builder (that violates referential transparency).
Unsafe builder (that violates referential transparency).
UNSAFE WARNING: this builder is unsafe to use
because creating a circuit breaker allocates shared mutable states,
which violates referential transparency. Prefer to use the safe
CircuitBreaker[F].of
and pass that CircuitBreaker
around as a plain parameter.
is the maximum count for failures before opening the circuit breaker
is the timeout to wait in the Open
state
before attempting a close of the circuit breaker (but without
the backoff factor applied)
is a factor to use for resetting
the resetTimeout
when in the HalfOpen
state, in case
the attempt to Close
fails
is the maximum timeout the circuit breaker
is allowed to use when applying the exponentialBackoffFactor
is the PaddingStrategy to apply to the underlying atomic reference used, to use in case contention and "false sharing" become a problem
CircuitBreaker[F].unsafe, the version that uses the "partially-applied type technique"