Packages

object TaskCircuitBreaker

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

Type Members

  1. final case class Closed(failures: Int) extends State with Product with Serializable

    The initial State of the TaskCircuitBreaker.

    The initial State of the TaskCircuitBreaker. 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

  2. final case class HalfOpen(resetTimeout: FiniteDuration) extends State with Product with Serializable

    State of the TaskCircuitBreaker 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 TaskCircuitBreaker 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)
    resetTimeout

    is the current resetTimeout that was applied to the previous Open state, to be multiplied by the exponential backoff factor for the next transition to Open, in case the reset attempt fails

  3. final case class Open(startedAt: Timestamp, resetTimeout: FiniteDuration) extends State with Product with Serializable

    State of the TaskCircuitBreaker in which the circuit breaker rejects all tasks with an ExecutionRejectedException.

    State of the TaskCircuitBreaker 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
    startedAt

    is the timestamp in milliseconds since the epoch when the transition to Open happened

    resetTimeout

    is the current resetTimeout that is applied to this Open state, to be multiplied by the exponential backoff factor for the next transition from HalfOpen to Open, in case the reset attempt fails

  4. sealed abstract class State extends AnyRef

    An enumeration that models the internal state of TaskCircuitBreaker, kept in an Atomic for synchronization.

    An enumeration that models the internal state of TaskCircuitBreaker, kept in an Atomic for synchronization.

    The initial state when initializing a TaskCircuitBreaker 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
  5. type Timestamp = Long

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

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(maxFailures: Int, resetTimeout: FiniteDuration, exponentialBackoffFactor: Double = 1.0, maxResetTimeout: Duration = Duration.Inf, onRejected: Task[Unit] = Task.unit, onClosed: Task[Unit] = Task.unit, onHalfOpen: Task[Unit] = Task.unit, onOpen: Task[Unit] = Task.unit, padding: PaddingStrategy = NoPadding): TaskCircuitBreaker

    Builder for a TaskCircuitBreaker reference.

    Builder for a TaskCircuitBreaker reference.

    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

    onRejected

    is for signaling rejected tasks

    onClosed

    is for signaling a transition to Closed

    onHalfOpen

    is for signaling a transition to HalfOpen

    onOpen

    is for signaling a transition to Open

    padding

    is the PaddingStrategy to apply to the underlying atomic reference used, to use in case contention and "false sharing" become a problem

  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. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  17. def toString(): String
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped