object CircuitBreaker extends CircuitBreakerDocs
- Alphabetic
- By Inheritance
- CircuitBreaker
- CircuitBreakerDocs
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
final
class
Builders[F[_]] extends AnyVal with CircuitBreakerDocs
Builders specified for CircuitBreaker, using the Partially-Applied Type technique.
-
final
case class
Closed(failures: Int) extends State with Product with Serializable
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:
- 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
- failures
is the current failures count
- Exceptions increment the
-
final
class
HalfOpen extends State
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)
- The first task when
-
final
class
Open extends State
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
- all tasks fail fast with
-
sealed abstract
class
State extends AnyRef
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
Timestamp = Long
Type-alias to document timestamps specified in milliseconds, as returned by Scheduler.clockRealTime.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
apply[F[_]](implicit F: Sync[F]): Builders[F]
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 )
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
of[F[_]](maxFailures: Int, resetTimeout: FiniteDuration, exponentialBackoffFactor: Double = 1.0, maxResetTimeout: Duration = Duration.Inf, padding: PaddingStrategy = NoPadding)(implicit F: Sync[F], clock: Clock[F]): F[CircuitBreaker[F]]
Safe builder.
Safe builder.
- maxFailures
is the maximum count for failures before opening the circuit breaker
- resetTimeout
is the timeout to wait in the
Open
state before attempting a close of the circuit breaker (but without the backoff factor applied)- exponentialBackoffFactor
is a factor to use for resetting the
resetTimeout
when in theHalfOpen
state, in case the attempt toClose
fails- maxResetTimeout
is the maximum timeout the circuit breaker is allowed to use when applying the
exponentialBackoffFactor
- padding
is the PaddingStrategy to apply to the underlying atomic reference used, to use in case contention and "false sharing" become a problem
- See also
CircuitBreaker[F].of, the version that uses the "partially-applied type technique"
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
unsafe[F[_]](maxFailures: Int, resetTimeout: FiniteDuration, exponentialBackoffFactor: Double = 1.0, maxResetTimeout: Duration = Duration.Inf, padding: PaddingStrategy = NoPadding)(implicit F: Sync[F], clock: Clock[F]): CircuitBreaker[F]
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.- maxFailures
is the maximum count for failures before opening the circuit breaker
- resetTimeout
is the timeout to wait in the
Open
state before attempting a close of the circuit breaker (but without the backoff factor applied)- exponentialBackoffFactor
is a factor to use for resetting the
resetTimeout
when in theHalfOpen
state, in case the attempt toClose
fails- maxResetTimeout
is the maximum timeout the circuit breaker is allowed to use when applying the
exponentialBackoffFactor
- padding
is the PaddingStrategy to apply to the underlying atomic reference used, to use in case contention and "false sharing" become a problem
- Annotations
- @UnsafeBecauseImpure()
- See also
CircuitBreaker[F].unsafe, the version that uses the "partially-applied type technique"
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- object HalfOpen
- object Open