fix circuitbreaker.md
This commit is contained in:
parent
59f53e1a22
commit
47682ecc72
3 changed files with 42 additions and 56 deletions
|
|
@ -7,8 +7,8 @@
|
|||
* [event-bus](event-bus.md)
|
||||
* [logging](logging.md)
|
||||
* [scheduler](scheduler.md)
|
||||
* [../scala/common/duration](../scala/common/duration.md)
|
||||
* [../scala/common/circuitbreaker](../scala/common/circuitbreaker.md)
|
||||
* [common/duration](common/duration.md)
|
||||
* [common/circuitbreaker](common/circuitbreaker.md)
|
||||
* [extending-akka](extending-akka.md)
|
||||
|
||||
@@@
|
||||
|
|
@ -29,57 +29,44 @@ The Akka library provides an implementation of a circuit breaker called
|
|||
|
||||
## What do they do?
|
||||
|
||||
*
|
||||
During normal operation, a circuit breaker is in the
|
||||
*Closed*
|
||||
state:
|
||||
:
|
||||
* Exceptions or calls exceeding the configured *callTimeout* increment a failure counter
|
||||
* Successes reset the failure count to zero
|
||||
* When the failure counter reaches a *maxFailures* count, the breaker is tripped into *Open* state
|
||||
* During normal operation, a circuit breaker is in the *Closed* state:
|
||||
|
||||
*
|
||||
While in
|
||||
*Open*
|
||||
state:
|
||||
:
|
||||
* All calls fail-fast with a `CircuitBreakerOpenException`
|
||||
* After the configured *resetTimeout*, the circuit breaker enters a *Half-Open* state
|
||||
- Exceptions or calls exceeding the configured *callTimeout* increment a failure counter
|
||||
- Successes reset the failure count to zero
|
||||
- When the failure counter reaches a *maxFailures* count, the breaker is tripped into *Open* state
|
||||
|
||||
*
|
||||
In
|
||||
*Half-Open*
|
||||
state:
|
||||
:
|
||||
* The first call attempted is allowed through without failing fast
|
||||
* All other calls fail-fast with an exception just as in *Open* state
|
||||
* If the first call succeeds, the breaker is reset back to *Closed* state and the *resetTimeout* is reset
|
||||
* If the first call fails, the breaker is tripped again into the *Open* state (as for exponential backoff circuit breaker, the *resetTimeout* is multiplied by the exponential backoff factor)
|
||||
* While in *Open* state:
|
||||
|
||||
*
|
||||
State transition listeners:
|
||||
:
|
||||
* Callbacks can be provided for every state entry via *onOpen*, *onClose*, and *onHalfOpen*
|
||||
* These are executed in the `ExecutionContext` provided.
|
||||
- All calls fail-fast with a `CircuitBreakerOpenException`
|
||||
- After the configured *resetTimeout*, the circuit breaker enters a *Half-Open* state
|
||||
|
||||
*
|
||||
Calls result listeners:
|
||||
:
|
||||
* Callbacks can be used eg. to collect statistics about all invocations or to react on specific call results like success, failures or timeouts.
|
||||
* Supported callbacks are: *onCallSuccess*, *onCallFailure*, *onCallTimeout*, *onCallBreakerOpen*.
|
||||
* These are executed in the `ExecutionContext` provided.
|
||||
* In *Half-Open* state:
|
||||
|
||||
- The first call attempted is allowed through without failing fast
|
||||
- All other calls fail-fast with an exception just as in *Open* state
|
||||
- If the first call succeeds, the breaker is reset back to *Closed* state and the *resetTimeout* is reset
|
||||
- If the first call fails, the breaker is tripped again into the *Open* state (as for exponential backoff circuit breaker, the *resetTimeout* is multiplied by the exponential backoff factor)
|
||||
|
||||
* State transition listeners:
|
||||
|
||||
- Callbacks can be provided for every state entry via *onOpen*, *onClose*, and *onHalfOpen*
|
||||
- These are executed in the `ExecutionContext` provided.
|
||||
|
||||
* Calls result listeners:
|
||||
|
||||
- Callbacks can be used eg. to collect statistics about all invocations or to react on specific call results like success, failures or timeouts.
|
||||
- Supported callbacks are: *onCallSuccess*, *onCallFailure*, *onCallTimeout*, *onCallBreakerOpen*.
|
||||
- These are executed in the `ExecutionContext` provided.
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
## Examples
|
||||
|
||||
### Initialization
|
||||
|
||||
Here's how a :class:
|
||||
*CircuitBreaker*
|
||||
would be configured for:
|
||||
:
|
||||
Here's how a `CircuitBreaker` would be configured for:
|
||||
|
||||
* 5 maximum failures
|
||||
* a call timeout of 10 seconds
|
||||
* a reset timeout of 1 minute
|
||||
|
|
@ -131,12 +118,11 @@ However, some applications might requires certain exception to not increase fail
|
|||
sometime we want to increase the failure count even if the call succeeded.
|
||||
Akka circuit breaker provides a way to achieve such use case:
|
||||
|
||||
>
|
||||
* *withCircuitBreaker*
|
||||
* *withSyncCircuitBreaker*
|
||||
* *callWithCircuitBreaker*
|
||||
* *callWithCircuitBreakerCS*
|
||||
* *callWithSyncCircuitBreaker*
|
||||
* `withCircuitBreaker`
|
||||
* `withSyncCircuitBreaker`
|
||||
* `callWithCircuitBreaker`
|
||||
* `callWithCircuitBreakerCS`
|
||||
* `callWithSyncCircuitBreaker`
|
||||
|
||||
All methods above accepts an argument `defineFailureFn`
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* [event-bus](event-bus.md)
|
||||
* [logging](logging.md)
|
||||
* [scheduler](scheduler.md)
|
||||
* [../scala/common/duration](../scala/common/duration.md)
|
||||
* [common/duration](../scala/common/duration.md)
|
||||
* [../scala/common/circuitbreaker](../scala/common/circuitbreaker.md)
|
||||
* [extending-akka](extending-akka.md)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue