Class

monadasync

CircuitBreaker

Related Doc: package monadasync

Permalink

case class CircuitBreaker[F[_]](maxFailures: Int, callTimeout: FiniteDuration, resetTimeout: FiniteDuration)(implicit evidence$1: MonadAsync[F], evidence$2: Catchable[F], evidence$3: Nondeterminism[F]) extends Product with Serializable

Provides circuit breaker functionality to provide stability when working with "dangerous" operations, e.g. calls to remote systems

Transitions through three states: - In *Closed* state, calls pass through until the maxFailures count is reached. This causes the circuit breaker to open. Both exceptions and calls exceeding callTimeout are considered failures. - In *Open* state, calls fail-fast with an exception. After resetTimeout, circuit breaker transitions to half-open state. - In *Half-Open* state, the first call will be allowed through, if it succeeds the circuit breaker will reset to closed state. If it fails, the circuit breaker will re-open to open state. All calls beyond the first that execute while the first is running will fail-fast with an exception.

maxFailures

Maximum number of failures before opening the circuit

callTimeout

scala.concurrent.duration.FiniteDuration of time after which to consider a call a failure

resetTimeout

scala.concurrent.duration.FiniteDuration of time after which to attempt to close the circuit

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. CircuitBreaker
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CircuitBreaker(maxFailures: Int, callTimeout: FiniteDuration, resetTimeout: FiniteDuration)(implicit arg0: MonadAsync[F], arg1: Catchable[F], arg2: Nondeterminism[F])

    Permalink

    maxFailures

    Maximum number of failures before opening the circuit

    callTimeout

    scala.concurrent.duration.FiniteDuration of time after which to consider a call a failure

    resetTimeout

    scala.concurrent.duration.FiniteDuration of time after which to attempt to close the circuit

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. val callTimeout: FiniteDuration

    Permalink

    scala.concurrent.duration.FiniteDuration of time after which to consider a call a failure

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  11. val maxFailures: Int

    Permalink

    Maximum number of failures before opening the circuit

  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. def onClose(callback: ⇒ Unit): CircuitBreaker[F]

    Permalink

    Adds a callback to execute when circuit breaker state closes

    Adds a callback to execute when circuit breaker state closes

    The callback is run in the scala.concurrent.ExecutionContext supplied in the constructor.

    callback

    Handler to be invoked on state change

    returns

    CircuitBreaker for fluent usage

  16. def onHalfOpen(callback: ⇒ Unit): CircuitBreaker[F]

    Permalink

    Adds a callback to execute when circuit breaker transitions to half-open

    Adds a callback to execute when circuit breaker transitions to half-open

    The callback is run in the scala.concurrent.ExecutionContext supplied in the constructor.

    callback

    Handler to be invoked on state change

    returns

    CircuitBreaker for fluent usage

  17. def onOpen(callback: ⇒ Unit): CircuitBreaker[F]

    Permalink

    Adds a callback to execute when circuit breaker opens

    Adds a callback to execute when circuit breaker opens

    The callback is run in the scala.concurrent.ExecutionContext supplied in the constructor.

    callback

    Handler to be invoked on state change

    returns

    CircuitBreaker for fluent usage

  18. val resetTimeout: FiniteDuration

    Permalink

    scala.concurrent.duration.FiniteDuration of time after which to attempt to close the circuit

  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  20. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. def withCircuitBreaker[T](body: ⇒ F[T]): F[T]

    Permalink

    Wraps invocations of asynchronous calls that need to be protected

    Wraps invocations of asynchronous calls that need to be protected

    body

    Call needing protected

    returns

    F containing the call result or a scala.concurrent.TimeoutException if the call timed out

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped