Packages

object CircuitBreaker

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CircuitBreaker
  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 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

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

    State of the CircuitBreaker in which the circuit breaker rejects all tasks with a RejectedExecution.

    State of the CircuitBreaker in which the circuit breaker rejects all tasks with a RejectedExecution.

    Contract:

    • all tasks fail fast with RejectedExecution
    • 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

  3. sealed trait Reason extends AnyRef
  4. final case class RejectedExecution(reason: Reason) extends RuntimeException with Product with Serializable

    Exception thrown whenever an execution attempt was rejected.

  5. sealed abstract class State extends AnyRef

    An enumeration that models the internal state of CircuitBreaker, kept in an AtomicReference for synchronization.

    An enumeration that models the internal state of CircuitBreaker, kept in an AtomicReference 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 Clock.realTime.

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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. def in[F[_], G[_]](maxFailures: Int, resetTimeout: FiniteDuration, exponentialBackoffFactor: Double, maxResetTimeout: Duration, onRejected: G[Unit], onClosed: G[Unit], onHalfOpen: G[Unit], onOpen: G[Unit])(implicit F: Sync[F], G: Sync[G], clock: Clock[G]): F[CircuitBreaker[G]]

    Builder for a CircuitBreaker reference.

    Builder for a CircuitBreaker reference.

    Effect returned by this operation produces a new CircuitBreaker each time it is evaluated. To share a state between multiple consumers, pass CircuitBreaker as a parameter

    This method returns a circuit breaker inside of a different effect from its own. For a simpler version, see CircuitBreaker.of.

    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

  11. def in[F[_], G[_]](maxFailures: Int, resetTimeout: FiniteDuration, exponentialBackoffFactor: Double = 1, maxResetTimeout: Duration = Duration.Inf)(implicit F: Sync[F], G: Sync[G], clock: Clock[G]): F[CircuitBreaker[G]]

    Builder for a CircuitBreaker reference.

    Builder for a CircuitBreaker reference.

    Effect returned by this operation produces a new CircuitBreaker each time it is evaluated. To share a state between multiple consumers, pass CircuitBreaker as a 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

  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def noop[F[_]](implicit F: Applicative[F]): CircuitBreaker[F]

    Creates a No-Operation circuit breaker which is always closed and passes through the effect.

  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  17. def of[F[_]](maxFailures: Int, resetTimeout: FiniteDuration, exponentialBackoffFactor: Double, maxResetTimeout: Duration, onRejected: F[Unit], onClosed: F[Unit], onHalfOpen: F[Unit], onOpen: F[Unit])(implicit F: Sync[F], clock: Clock[F]): F[CircuitBreaker[F]]

    Builder for a CircuitBreaker reference.

    Builder for a CircuitBreaker reference.

    Effect returned by this operation produces a new CircuitBreaker each time it is evaluated. To share a state between multiple consumers, pass CircuitBreaker as a 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

    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

  18. def of[F[_]](maxFailures: Int, resetTimeout: FiniteDuration, exponentialBackoffFactor: Double = 1, maxResetTimeout: Duration = Duration.Inf)(implicit F: Sync[F], clock: Clock[F]): F[CircuitBreaker[F]]

    Builder for a CircuitBreaker reference.

    Builder for a CircuitBreaker reference.

    Effect returned by this operation produces a new CircuitBreaker each time it is evaluated. To share a state between multiple consumers, pass CircuitBreaker as a 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

  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. def unsafe[G[_]](ref: Ref[G, State], maxFailures: Int, resetTimeout: FiniteDuration, exponentialBackoffFactor: Double, maxResetTimeout: Duration, onRejected: G[Unit], onClosed: G[Unit], onHalfOpen: G[Unit], onOpen: G[Unit])(implicit arg0: Sync[G], arg1: Clock[G]): CircuitBreaker[G]

    For Custom Ref Implementations Ideally this will be in some valid state for the state machine and that maxFailures/resetTimeout/exponentialBackoffFactor/maxResetTimeout will all be consistent across users or else you may wait based on incorrect information.

  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. object HalfOpen extends State with Reason with Product with Serializable

    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)

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped