object CircuitBreaker extends CircuitBreakerDocs
- Source
- CircuitBreaker.scala
- 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
failurescounter - Successes reset the failure count to zero
- When the
failurescounter reaches themaxFailurescount, the breaker is tripped into theOpenstate
- 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
Openhas expired is allowed through without failing fast, just before the circuit breaker is evolved into theHalfOpenstate - All tasks attempted in
HalfOpenfail-fast with an exception just as in Open state - If that task attempt succeeds, the breaker is reset back to
the
Closedstate, with theresetTimeoutand thefailurescount also reset to initial values - If the first call fails, the breaker is tripped again into
the
Openstate (theresetTimeoutis 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
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): 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[_ <: AnyRef]
- 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
Openstate before attempting a close of the circuit breaker (but without the backoff factor applied)- exponentialBackoffFactor
is a factor to use for resetting the
resetTimeoutwhen in theHalfOpenstate, in case the attempt toClosefails- 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
CircuitBreakeraround as a plain parameter.- maxFailures
is the maximum count for failures before opening the circuit breaker
- resetTimeout
is the timeout to wait in the
Openstate before attempting a close of the circuit breaker (but without the backoff factor applied)- exponentialBackoffFactor
is a factor to use for resetting the
resetTimeoutwhen in theHalfOpenstate, in case the attempt toClosefails- 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(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- object HalfOpen
- object Open

This is the API documentation for the Monix library.
Package Overview
monix.execution exposes lower level primitives for dealing with asynchronous execution:
Atomictypes, as alternative tojava.util.concurrent.atomicmonix.catnap exposes pure abstractions built on top of the Cats-Effect type classes:
monix.eval is for dealing with evaluation of results, thus exposing Task and Coeval.
monix.reactive exposes the
Observablepattern:Observableimplementationsmonix.tail exposes Iterant for purely functional pull based streaming:
BatchandBatchCursor, the alternatives to Scala'sIterableandIteratorrespectively that we are using within Iterant's encodingYou can control evaluation with type you choose - be it Task, Coeval, cats.effect.IO or your own as long as you provide correct cats-effect or cats typeclass instance.