akka.pattern

CircuitBreaker

class CircuitBreaker extends AbstractCircuitBreaker

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.

Source
CircuitBreaker.scala
Linear Supertypes
AbstractCircuitBreaker, AnyRef, Any
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. CircuitBreaker
  2. AbstractCircuitBreaker
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CircuitBreaker(executor: ExecutionContext, scheduler: Scheduler, maxFailures: Int, callTimeout: FiniteDuration, resetTimeout: FiniteDuration)

  2. new CircuitBreaker(scheduler: Scheduler, maxFailures: Int, callTimeout: FiniteDuration, resetTimeout: FiniteDuration)(implicit executor: ExecutionContext)

    scheduler

    Reference to Akka scheduler

    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

    executor

    scala.concurrent.ExecutionContext used for execution of state transition listeners

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (CircuitBreaker, B)

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to ArrowAssoc[CircuitBreaker] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def callWithCircuitBreaker[T](body: Callable[Future[T]]): Future[T]

    Java API for #withCircuitBreaker

    Java API for #withCircuitBreaker

    T

    return type from call

    body

    Call needing protected

    returns

    scala.concurrent.Future containing the call result

  10. def callWithSyncCircuitBreaker[T](body: Callable[T]): T

    Java API for #withSyncCircuitBreaker

    T

    return type from call

    body

    Call needing protected

    returns

    The result of the call

  11. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def ensuring(cond: (CircuitBreaker) ⇒ Boolean, msg: ⇒ Any): CircuitBreaker

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to Ensuring[CircuitBreaker] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: (CircuitBreaker) ⇒ Boolean): CircuitBreaker

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to Ensuring[CircuitBreaker] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean, msg: ⇒ Any): CircuitBreaker

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to Ensuring[CircuitBreaker] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean): CircuitBreaker

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to Ensuring[CircuitBreaker] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  20. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  21. def hashCode(): Int

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

    Definition Classes
    Any
  23. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  24. final def notify(): Unit

    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  26. def onClose(callback: Runnable): CircuitBreaker

    JavaAPI for onClose

    JavaAPI for onClose

    callback

    Handler to be invoked on state change

    returns

    CircuitBreaker for fluent usage

  27. def onClose(callback: ⇒ Unit): CircuitBreaker

    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

  28. def onHalfOpen(callback: Runnable): CircuitBreaker

    JavaAPI for onHalfOpen

    JavaAPI for onHalfOpen

    callback

    Handler to be invoked on state change

    returns

    CircuitBreaker for fluent usage

  29. def onHalfOpen(callback: ⇒ Unit): CircuitBreaker

    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

  30. def onOpen(callback: Runnable): CircuitBreaker

    Java API for onOpen

    Java API for onOpen

    callback

    Handler to be invoked on state change

    returns

    CircuitBreaker for fluent usage

  31. def onOpen(callback: ⇒ Unit): CircuitBreaker

    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

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

    Definition Classes
    AnyRef
  33. def toString(): String

    Definition Classes
    AnyRef → Any
  34. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. def withCircuitBreaker[T](body: ⇒ Future[T]): Future[T]

    Wraps invocations of asynchronous calls that need to be protected

    Wraps invocations of asynchronous calls that need to be protected

    T

    return type from call

    body

    Call needing protected

    returns

    scala.concurrent.Future containing the call result

  38. def withSyncCircuitBreaker[T](body: ⇒ T): T

    Wraps invocations of synchronous calls that need to be protected

    Wraps invocations of synchronous calls that need to be protected

    Calls are run in caller's thread

    T

    return type from call

    body

    Call needing protected

    returns

    The result of the call

  39. def [B](y: B): (CircuitBreaker, B)

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to ArrowAssoc[CircuitBreaker] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (circuitBreaker: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (circuitBreaker: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def x: CircuitBreaker

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to ArrowAssoc[CircuitBreaker] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (circuitBreaker: ArrowAssoc[CircuitBreaker]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  2. def x: CircuitBreaker

    Implicit information
    This member is added by an implicit conversion from CircuitBreaker to Ensuring[CircuitBreaker] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (circuitBreaker: Ensuring[CircuitBreaker]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from AbstractCircuitBreaker

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from CircuitBreaker to StringAdd

Inherited by implicit conversion any2stringfmt from CircuitBreaker to StringFormat

Inherited by implicit conversion any2ArrowAssoc from CircuitBreaker to ArrowAssoc[CircuitBreaker]

Inherited by implicit conversion any2Ensuring from CircuitBreaker to Ensuring[CircuitBreaker]

Ungrouped