Class CircuitBreakerRpcClient
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<RpcRequest,RpcResponse>
com.linecorp.armeria.client.circuitbreaker.CircuitBreakerRpcClient
- All Implemented Interfaces:
Client<RpcRequest,
,RpcResponse> RpcClient
,Unwrappable
public final class CircuitBreakerRpcClient
extends AbstractCircuitBreakerClient<RpcRequest,RpcResponse>
implements RpcClient
An
RpcClient
decorator that handles failures of RPC remote invocation based on
circuit breaker pattern.-
Method Summary
Modifier and TypeMethodDescriptionbuilder
(CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Returns a newCircuitBreakerRpcClientBuilder
with the specifiedCircuitBreakerRuleWithContent
.protected RpcResponse
doExecute
(ClientRequestContext ctx, RpcRequest req, CircuitBreaker circuitBreaker) Invoked when theCircuitBreaker
is in closed state.static Function<? super RpcClient,
CircuitBreakerRpcClient> newDecorator
(CircuitBreakerMapping mapping, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Creates a new decorator with the specifiedCircuitBreakerMapping
andCircuitBreakerRuleWithContent
.static Function<? super RpcClient,
CircuitBreakerRpcClient> newDecorator
(CircuitBreaker circuitBreaker, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Creates a new decorator using the specifiedCircuitBreaker
instance andCircuitBreakerRuleWithContent
.static Function<? super RpcClient,
CircuitBreakerRpcClient> newPerHostAndMethodDecorator
(BiFunction<String, String, ? extends CircuitBreaker> factory, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Deprecated.static Function<? super RpcClient,
CircuitBreakerRpcClient> newPerHostDecorator
(Function<String, ? extends CircuitBreaker> factory, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Creates a new decorator that binds oneCircuitBreaker
per host with the specifiedCircuitBreakerRuleWithContent
.static Function<? super RpcClient,
CircuitBreakerRpcClient> newPerMethodDecorator
(Function<String, ? extends CircuitBreaker> factory, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Creates a new decorator that binds oneCircuitBreaker
per RPC method name with the specifiedCircuitBreakerRuleWithContent
.Methods inherited from class com.linecorp.armeria.client.circuitbreaker.AbstractCircuitBreakerClient
execute, reportSuccessOrFailure
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap, unwrapAll
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
Method Details
-
newDecorator
public static Function<? super RpcClient,CircuitBreakerRpcClient> newDecorator(CircuitBreaker circuitBreaker, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Creates a new decorator using the specifiedCircuitBreaker
instance andCircuitBreakerRuleWithContent
.Since
CircuitBreaker
is a unit of failure detection, don't reuse the same instance for unrelated services.- Parameters:
circuitBreaker
- TheCircuitBreaker
instance to be used
-
newDecorator
public static Function<? super RpcClient,CircuitBreakerRpcClient> newDecorator(CircuitBreakerMapping mapping, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Creates a new decorator with the specifiedCircuitBreakerMapping
andCircuitBreakerRuleWithContent
.Since
CircuitBreaker
is a unit of failure detection, don't reuse the same instance for unrelated services. -
newPerMethodDecorator
public static Function<? super RpcClient,CircuitBreakerRpcClient> newPerMethodDecorator(Function<String, ? extends CircuitBreaker> factory, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Creates a new decorator that binds oneCircuitBreaker
per RPC method name with the specifiedCircuitBreakerRuleWithContent
.Since
CircuitBreaker
is a unit of failure detection, don't reuse the same instance for unrelated services.- Parameters:
factory
- A function that takes an RPC method name and creates a newCircuitBreaker
.
-
newPerHostDecorator
public static Function<? super RpcClient,CircuitBreakerRpcClient> newPerHostDecorator(Function<String, ? extends CircuitBreaker> factory, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Creates a new decorator that binds oneCircuitBreaker
per host with the specifiedCircuitBreakerRuleWithContent
.Since
CircuitBreaker
is a unit of failure detection, don't reuse the same instance for unrelated services.- Parameters:
factory
- a function that takes a host name and creates a newCircuitBreaker
-
newPerHostAndMethodDecorator
@Deprecated public static Function<? super RpcClient,CircuitBreakerRpcClient> newPerHostAndMethodDecorator(BiFunction<String, String, ? extends CircuitBreaker> factory, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Deprecated.Creates a new decorator that binds oneCircuitBreaker
per host and RPC method name with the specifiedCircuitBreakerRuleWithContent
.Since
CircuitBreaker
is a unit of failure detection, don't reuse the same instance for unrelated services.- Parameters:
factory
- a function that takes a host+method and creates a newCircuitBreaker
-
builder
public static CircuitBreakerRpcClientBuilder builder(CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) Returns a newCircuitBreakerRpcClientBuilder
with the specifiedCircuitBreakerRuleWithContent
. -
doExecute
protected RpcResponse doExecute(ClientRequestContext ctx, RpcRequest req, CircuitBreaker circuitBreaker) throws Exception Description copied from class:AbstractCircuitBreakerClient
Invoked when theCircuitBreaker
is in closed state.- Specified by:
doExecute
in classAbstractCircuitBreakerClient<RpcRequest,
RpcResponse> - Throws:
Exception
-
newDecorator(CircuitBreakerMapping, CircuitBreakerRuleWithContent)
withCircuitBreakerMapping.perHostAndMethod(BiFunction)
.