case class CircuitBreaker(name: String = "default", healthCheckPolicy: HealthCheckPolicy = ..., resultClassifier: (Any) ⇒ ResultClass = ResultClass.ALWAYS_SUCCEED, errorClassifier: (Throwable) ⇒ Failed = ResultClass.ALWAYS_RETRY, onOpenFailureHandler: (CircuitBreakerContext) ⇒ Unit = CircuitBreaker.throwOpenException, onStateChangeListener: (CircuitBreakerContext) ⇒ Unit = CircuitBreaker.reportStateChange, fallbackHandler: (Throwable) ⇒ Any = t => throw t, delayAfterMarkedDead: RetryPolicy = ..., recoveryPolicy: CircuitBreakerRecoveryPolicy = ..., nextProvingTimeMillis: Long = Long.MaxValue, provingWaitTimeMillis: Long = 0L, lastFailure: Option[Throwable] = None, currentState: AtomicReference[CircuitBreakerState] = ...) extends CircuitBreakerContext with LogSupport with Product with Serializable
- Alphabetic
- By Inheritance
- CircuitBreaker
- Product
- Equals
- LogSupport
- LazyLogger
- LoggingMethods
- Serializable
- Serializable
- CircuitBreakerContext
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new CircuitBreaker(name: String = "default", healthCheckPolicy: HealthCheckPolicy = ..., resultClassifier: (Any) ⇒ ResultClass = ResultClass.ALWAYS_SUCCEED, errorClassifier: (Throwable) ⇒ Failed = ResultClass.ALWAYS_RETRY, onOpenFailureHandler: (CircuitBreakerContext) ⇒ Unit = CircuitBreaker.throwOpenException, onStateChangeListener: (CircuitBreakerContext) ⇒ Unit = CircuitBreaker.reportStateChange, fallbackHandler: (Throwable) ⇒ Any = t => throw t, delayAfterMarkedDead: RetryPolicy = ..., recoveryPolicy: CircuitBreakerRecoveryPolicy = ..., nextProvingTimeMillis: Long = Long.MaxValue, provingWaitTimeMillis: Long = 0L, lastFailure: Option[Throwable] = None, currentState: AtomicReference[CircuitBreakerState] = ...)
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()
- def close: CircuitBreaker.this.type
-
macro
def
debug(message: Any, cause: Throwable): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
macro
def
debug(message: Any): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
- val delayAfterMarkedDead: RetryPolicy
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
macro
def
error(message: Any, cause: Throwable): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
macro
def
error(message: Any): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
- val errorClassifier: (Throwable) ⇒ Failed
- val fallbackHandler: (Throwable) ⇒ Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def halfOpen: CircuitBreaker.this.type
- val healthCheckPolicy: HealthCheckPolicy
-
macro
def
info(message: Any, cause: Throwable): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
macro
def
info(message: Any): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
def
isConnected: Boolean
Returns true when the circuit can execute the code ( OPEN or HALF_OPEN state)
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
var
lastFailure: Option[Throwable]
- Definition Classes
- CircuitBreaker → CircuitBreakerContext
-
macro
def
logAt(logLevel: LogLevel, message: Any): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
lazy val
logger: Logger
- Attributes
- protected[this]
- Definition Classes
- LazyLogger
-
val
name: String
- Definition Classes
- CircuitBreaker → CircuitBreakerContext
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
onOpenFailure(handler: (CircuitBreakerContext) ⇒ Unit): CircuitBreaker
Defines the action when trying to use the open circuit.
Defines the action when trying to use the open circuit. The default behavior is to throw CircuitBreakerOpenException
- val onOpenFailureHandler: (CircuitBreakerContext) ⇒ Unit
-
def
onStateChange(listener: (CircuitBreakerContext) ⇒ Unit): CircuitBreaker
Set an event listener that monitors CircuitBreaker state changes
- val onStateChangeListener: (CircuitBreakerContext) ⇒ Unit
- def open: CircuitBreaker.this.type
-
def
recordFailure(e: Throwable): Unit
Note: Use this method only for the standalone mode.
Note: Use this method only for the standalone mode. Generally, using CircuitBreaker.run is sufficient.
This method reports a failure state to the CircuitBreaker.
-
def
recordSuccess: Unit
Note: Use this method only for the standalone mode.
Note: Use this method only for the standalone mode. Generally, using CircuitBreaker.run is sufficient.
This method reports a successful state to the CircuitBreaker.
- val recoveryPolicy: CircuitBreakerRecoveryPolicy
-
def
reset: Unit
Reset the lastFailure and close the circuit
- val resultClassifier: (Any) ⇒ ResultClass
-
def
run[A](body: ⇒ A)(implicit arg0: ClassTag[A]): A
Execute the body block through the CircuitBreaker.
Execute the body block through the CircuitBreaker.
If the state is OPEN, this will throw CircuitBreakerOpenException (fail-fast). The state will move to HALF_OPEN state after a certain amount of delay, determined by the delayAfterMarkedDead policy.
If the state is HALF_OPEN, this method allows running the code block once, and if the result is successful, the state will move to CLOSED. If not, the state will be OPEN again.
If the state is CLOSED, the code block will be executed normally. If the result is marked failure or nonRetryable exception is thrown, it will report to the failure to the HealthCheckPolicy. If this policy determines the target service is dead, the circuit will shift to OPEN state to block the future execution.
-
def
setState(newState: CircuitBreakerState): CircuitBreaker.this.type
Force setting the current state.
-
def
state: CircuitBreakerState
- Definition Classes
- CircuitBreaker → CircuitBreakerContext
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
macro
def
trace(message: Any, cause: Throwable): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
macro
def
trace(message: Any): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
def
verifyConnection: Unit
Note: Use this method only for the standalone mode.
Note: Use this method only for the standalone mode. Generally, using CircuiteBreaker.run is sufficient.
If the connection is open, perform the specified action. The default behavior is fail-fast, i.e., throwing CircuitBreakerOpenException
-
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( ... )
-
macro
def
warn(message: Any, cause: Throwable): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
macro
def
warn(message: Any): Unit
- Attributes
- protected
- Definition Classes
- LoggingMethods
-
def
withDelayAfterMarkedDead(retryPolicy: RetryPolicy): CircuitBreaker
Set a delay policy until moving the state from OPEN to HALF_OPEN (probing) state.
Set a delay policy until moving the state from OPEN to HALF_OPEN (probing) state. The default is Jittered-exponential backoff delay with the initial interval of 30 seconds.
-
def
withErrorClassifier(newErrorClassifier: (Throwable) ⇒ Failed): CircuitBreaker
Set a classifier to determine whether the exception happened in the code block can be ignoreable or not for the accessing the target service.
-
def
withFallbackHandler(handler: (Throwable) ⇒ Any): CircuitBreaker
Set a fallback handler which process the exception happened in the code block.
Set a fallback handler which process the exception happened in the code block. The default is just throwing the exception as it is.
-
def
withHealthCheckPolicy(newHealthCheckPolicy: HealthCheckPolicy): CircuitBreaker
Set a health check policy, which will be used to determine the state of the target service.
-
def
withName(newName: String): CircuitBreaker
Set the name of this CircuitBreaker
-
def
withRecoveryPolicy(recoveryPolicy: CircuitBreakerRecoveryPolicy): CircuitBreaker
Set a recovery policiy which determine if ths circuit breaker can recover from HALF_OPEN to CLOSED.
Set a recovery policiy which determine if ths circuit breaker can recover from HALF_OPEN to CLOSED. The default policy recovers immediately if health check is once successful.
-
def
withResultClassifier(newResultClassifier: (Any) ⇒ ResultClass): CircuitBreaker
Set a classifier to determine whether the execution result of the code block is successful or not.
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated