object CircuitBreaker
- Alphabetic
- By Inheritance
- CircuitBreaker
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
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 themaxFailures
count, the breaker is tripped into theOpen
state
- failures
is the current failures count
- Exceptions increment the
-
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 thisOpen
state, to be multiplied by the exponential backoff factor for the next transition fromHalfOpen
toOpen
, in case the reset attempt fails
- all tasks fail fast with
- sealed trait Reason extends AnyRef
-
final
case class
RejectedExecution(reason: Reason) extends RuntimeException with Product with Serializable
Exception thrown whenever an execution attempt was rejected.
-
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:
-
type
Timestamp = Long
Type-alias to document timestamps specified in milliseconds, as returned by Clock.realTime.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
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 theHalfOpen
state, in case the attempt toClose
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
-
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 theHalfOpen
state, in case the attempt toClose
fails- maxResetTimeout
is the maximum timeout the circuit breaker is allowed to use when applying the
exponentialBackoffFactor
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
noop[F[_]](implicit F: Applicative[F]): CircuitBreaker[F]
Creates a No-Operation circuit breaker which is always closed and passes through the effect.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
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 theHalfOpen
state, in case the attempt toClose
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
-
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 theHalfOpen
state, in case the attempt toClose
fails- maxResetTimeout
is the maximum timeout the circuit breaker is allowed to use when applying the
exponentialBackoffFactor
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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.
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
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 theHalfOpen
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 theresetTimeout
and thefailures
count also reset to initial values - If the first call fails, the breaker is tripped again into
the
Open
state (theresetTimeout
is multiplied by the exponential backoff factor)
- The first task when
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated