public abstract class AbstractCircuitBreakerClient<I extends Request,O extends Response> extends SimpleDecoratingClient<I,O>
Client decorator that handles failures of remote invocation based on circuit breaker pattern.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCircuitBreakerClient(Client<I,O> delegate,
CircuitBreakerMapping mapping,
CircuitBreakerStrategy strategy)
Creates a new instance that decorates the specified
Client. |
protected |
AbstractCircuitBreakerClient(Client<I,O> delegate,
CircuitBreakerMapping mapping,
CircuitBreakerStrategyWithContent<O> strategyWithContent)
Creates a new instance that decorates the specified
Client. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract O |
doExecute(ClientRequestContext ctx,
I req,
CircuitBreaker circuitBreaker)
Invoked when the
CircuitBreaker is in closed state. |
O |
execute(ClientRequestContext ctx,
I req)
|
protected static void |
reportSuccessOrFailure(CircuitBreaker circuitBreaker,
CompletionStage<Boolean> future)
Reports a success or a failure to the specified
CircuitBreaker according to the completed value
of the specified future. |
protected CircuitBreakerStrategy |
strategy()
Returns the
CircuitBreakerStrategy. |
protected CircuitBreakerStrategyWithContent<O> |
strategyWithContent()
Returns the
CircuitBreakerStrategyWithContent. |
as, delegate, toStringprotected AbstractCircuitBreakerClient(Client<I,O> delegate, CircuitBreakerMapping mapping, CircuitBreakerStrategy strategy)
Client.protected AbstractCircuitBreakerClient(Client<I,O> delegate, CircuitBreakerMapping mapping, CircuitBreakerStrategyWithContent<O> strategyWithContent)
Client.protected final CircuitBreakerStrategy strategy()
CircuitBreakerStrategy.IllegalStateException - if the CircuitBreakerStrategy is not setprotected final CircuitBreakerStrategyWithContent<O> strategyWithContent()
CircuitBreakerStrategyWithContent.IllegalStateException - if the CircuitBreakerStrategyWithContent is not setpublic O execute(ClientRequestContext ctx, I req) throws Exception
Clientprotected abstract O doExecute(ClientRequestContext ctx, I req, CircuitBreaker circuitBreaker) throws Exception
CircuitBreaker is in closed state.Exceptionprotected static void reportSuccessOrFailure(CircuitBreaker circuitBreaker, CompletionStage<Boolean> future)
CircuitBreaker according to the completed value
of the specified future. If the completed value is null, this doesn't do anything.Copyright © 2020 LeanCloud. All rights reserved.