java.lang.Object
com.linecorp.armeria.common.util.AbstractUnwrappable<Client<T_I,T_O>>
com.linecorp.armeria.client.DecoratingClient<I,O,I,O>
com.linecorp.armeria.client.SimpleDecoratingClient<I,O>
com.linecorp.armeria.client.circuitbreaker.AbstractCircuitBreakerClient<I,O>
- All Implemented Interfaces:
Client<I,O>
,Unwrappable
- Direct Known Subclasses:
CircuitBreakerClient
,CircuitBreakerRpcClient
public abstract class AbstractCircuitBreakerClient<I extends Request,O extends Response> extends SimpleDecoratingClient<I,O>
A
Client
decorator that handles failures of remote invocation based on circuit breaker pattern.-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCircuitBreakerClient(Client<I,O> delegate, CircuitBreakerMapping mapping, CircuitBreakerStrategy strategy)
Creates a new instance that decorates the specifiedClient
.protected
AbstractCircuitBreakerClient(Client<I,O> delegate, CircuitBreakerMapping mapping, CircuitBreakerStrategyWithContent<O> strategyWithContent)
Creates a new instance that decorates the specifiedClient
. -
Method Summary
Modifier and Type Method Description protected abstract O
doExecute(ClientRequestContext ctx, I req, CircuitBreaker circuitBreaker)
Invoked when theCircuitBreaker
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 specifiedCircuitBreaker
according to the completed value of the specifiedfuture
.protected CircuitBreakerStrategy
strategy()
Returns theCircuitBreakerStrategy
.protected CircuitBreakerStrategyWithContent<O>
strategyWithContent()
Returns theCircuitBreakerStrategyWithContent
.Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, delegate, toString
-
Constructor Details
-
AbstractCircuitBreakerClient
protected AbstractCircuitBreakerClient(Client<I,O> delegate, CircuitBreakerMapping mapping, CircuitBreakerStrategy strategy)Creates a new instance that decorates the specifiedClient
. -
AbstractCircuitBreakerClient
protected AbstractCircuitBreakerClient(Client<I,O> delegate, CircuitBreakerMapping mapping, CircuitBreakerStrategyWithContent<O> strategyWithContent)Creates a new instance that decorates the specifiedClient
.
-
-
Method Details
-
strategy
Returns theCircuitBreakerStrategy
.- Throws:
IllegalStateException
- if theCircuitBreakerStrategy
is not set
-
strategyWithContent
Returns theCircuitBreakerStrategyWithContent
.- Throws:
IllegalStateException
- if theCircuitBreakerStrategyWithContent
is not set
-
execute
Description copied from interface:Client
-
doExecute
protected abstract O doExecute(ClientRequestContext ctx, I req, CircuitBreaker circuitBreaker) throws ExceptionInvoked when theCircuitBreaker
is in closed state.- Throws:
Exception
-
reportSuccessOrFailure
protected static void reportSuccessOrFailure(CircuitBreaker circuitBreaker, CompletionStage<Boolean> future)Reports a success or a failure to the specifiedCircuitBreaker
according to the completed value of the specifiedfuture
. If the completed value isnull
, this doesn't do anything.
-