object TaskCircuitBreaker
- Source
- TaskCircuitBreaker.scala
- Alphabetic
- By Inheritance
- TaskCircuitBreaker
- 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 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 themaxFailures
count, the breaker is tripped into theOpen
state
- failures
is the current failures count
- Exceptions increment the
-
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 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)
- resetTimeout
is the current
resetTimeout
that was applied to the previousOpen
state, to be multiplied by the exponential backoff factor for the next transition toOpen
, in case the reset attempt fails
- The first task when
-
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 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 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:
-
type
Timestamp = Long
Type-alias to document timestamps specified in milliseconds, as returned by Scheduler.currentTimeMillis.
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
-
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 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
- padding
is the PaddingStrategy to apply to the underlying atomic reference used, to use in case contention and "false sharing" become a problem
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
This is the API documentation for the Monix library.
Package Overview
monix.execution exposes lower level primitives for dealing with asynchronous execution:
Atomic
types, as alternative tojava.util.concurrent.atomic
monix.eval is for dealing with evaluation of results, thus exposing Task and Coeval.
monix.reactive exposes the
Observable
pattern:Observable
implementationsmonix.types implements type-class shims, to be translated to type-classes provided by libraries such as Cats or Scalaz.
monix.cats is the optional integration with the Cats library, providing translations for the types described in
monix.types
.monix.scalaz is the optional integration with the Scalaz library, providing translations for the types described in
monix.types
.