See: Description
| Interface | Description |
|---|---|
| CircuitBreaker |
A circuit breaker, which tracks the number of
success/failure requests and detects a remote service failure.
|
| CircuitBreakerListener |
The listener interface for receiving
CircuitBreaker events. |
| CircuitBreakerMapping |
Returns a
CircuitBreaker instance from remote invocation parameters. |
| CircuitBreakerStrategy |
Determines whether a
Response should be reported as a success or a failure to a
CircuitBreaker. |
| CircuitBreakerStrategyWithContent<T extends Response> |
Determines whether a
Response should be reported as a success or a failure to a
CircuitBreaker using the content of a Response. |
| KeyedCircuitBreakerMapping.KeySelector<K> |
Returns the mapping key of the given
Request. |
| Class | Description |
|---|---|
| AbstractCircuitBreakerClient<I extends Request,O extends Response> |
A
Client decorator that handles failures of remote invocation based on circuit breaker pattern. |
| AbstractCircuitBreakerClientBuilder<O extends Response> |
A skeletal builder implementation that builds a new
AbstractCircuitBreakerClient or
its decorator function. |
| CircuitBreakerBuilder |
Builds a
CircuitBreaker instance using builder pattern. |
| CircuitBreakerClient |
An
HttpClient decorator that handles failures of HTTP requests based on circuit breaker pattern. |
| CircuitBreakerClientBuilder |
Builds a new
CircuitBreakerClient or its decorator function. |
| CircuitBreakerHttpClient | Deprecated
Use
CircuitBreakerClient. |
| CircuitBreakerHttpClientBuilder | Deprecated |
| CircuitBreakerListenerAdapter |
A skeletal
CircuitBreakerListener implementation in order for a user to implement only the methods
what he or she really needs. |
| CircuitBreakerRpcClient |
An
RpcClient decorator that handles failures of RPC remote invocation based on
circuit breaker pattern. |
| CircuitBreakerRpcClientBuilder |
Builds a new
CircuitBreakerRpcClient or its decorator function. |
| EventCount |
An immutable object that stores the count of events.
|
| KeyedCircuitBreakerMapping<K> |
A
CircuitBreakerMapping that binds a CircuitBreaker to its key. |
| MetricCollectingCircuitBreakerListener |
| Enum | Description |
|---|---|
| CircuitState |
Defines the states of circuit breaker.
|
| Exception | Description |
|---|---|
| FailFastException |
An exception indicating that a request has been failed by circuit breaker.
|
Iface helloClient =
Clients.builder("tbinary+http://127.0.0.1:8080/hello")
.decorator(CircuitBreakerClient.newDecorator(
CircuitBreaker.builder("hello").build()))
.build(Iface.class);
// Setup with per-method failure detection
AsyncIface helloClient =
Clients.builder("tbinary+http://127.0.0.1:8080/hello")
.decorator(CircuitBreakerClient.newPerMethodDecorator(
method -> CircuitBreaker.builder(method).build()))
.build(AsyncIface.class);
FailFastException is thrown
from the client. You can write a fallback code by catching the exception.
try {
helloClient.hello("line");
} catch (TException e) {
// error handling
} catch (FailFastException e) {
// fallback code
}
helloClient.hello("line", new AsyncMethodCallback() {
public void onComplete(Object response) {
// response handling
}
public void onError(Exception e) {
if (e instanceof TException) {
// error handling
} else if (e instanceof FailFastException) {
// fallback code
}
}
});
CLOSEDOPEN.
OPENHALF_OPEN.
HALF_OPENCLOSED.OPEN.CircuitBreakerBuilder.
failureRateThresholdminimumRequestThresholdcircuitOpenWindowOPEN state.
trialRequestIntervalHALF_OPEN state.
counterSlidingWindowcounterUpdateIntervalexceptionFilterCopyright © 2020 LeanCloud. All rights reserved.