Packages

object CircuitBreaker extends CircuitBreakerDocs

Source
CircuitBreaker.scala
Linear Supertypes
CircuitBreakerDocs, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CircuitBreaker
  2. CircuitBreakerDocs
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final class Builders[F[_]] extends AnyVal with CircuitBreakerDocs

    Builders specified for CircuitBreaker, using the Partially-Applied Type technique.

  2. 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 the maxFailures count, the breaker is tripped into the Open state
    failures

    is the current failures count

  3. 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 the HalfOpen 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 the resetTimeout and the failures count also reset to initial values
    • If the first call fails, the breaker is tripped again into the Open state (the resetTimeout is multiplied by the exponential backoff factor)
  4. 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
  5. 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:

    • Closed in case tasks are allowed to go through
    • Open in case the circuit breaker is active and rejects incoming tasks
    • HalfOpen in case a reset attempt was triggered and it is waiting for the result in order to evolve in Closed, or back to Open
  6. type Timestamp = Long

    Type-alias to document timestamps specified in milliseconds, as returned by Scheduler.clockRealTime.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. 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
    )
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. 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 the HalfOpen state, in case the attempt to Close 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"

  17. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. 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 the HalfOpen state, in case the attempt to Close 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"

  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  23. object HalfOpen
  24. object Open

Inherited from CircuitBreakerDocs

Inherited from AnyRef

Inherited from Any

Ungrouped