CircuitBreakerRpcClient extends AbstractCircuitBreakerClient<RpcRequest, RpcResponse> implements RpcClient { public static Function<? super RpcClient, CircuitBreakerRpcClient> newDecorator(CircuitBreaker circuitBreaker, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent) { requireNonNull(circuitBreaker, "circuitBreaker"); return newDecorator((ctx, req) -> circuitBreaker, ruleWithContent); } CircuitBreakerRpcClient(RpcClient delegate, CircuitBreakerMapping mapping,
                            CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent); static Function<? super RpcClient, CircuitBreakerRpcClient> newDecorator(CircuitBreaker circuitBreaker, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent); static Function<? super RpcClient, CircuitBreakerRpcClient> newDecorator(CircuitBreakerMapping mapping, CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent); static Function<? super RpcClient, CircuitBreakerRpcClient> newPerMethodDecorator(Function<String, ? extends CircuitBreaker> factory,
                          CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent); static Function<? super RpcClient, CircuitBreakerRpcClient> newPerHostDecorator(Function<String, ? extends CircuitBreaker> factory,
                        CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent); static Function<? super RpcClient, CircuitBreakerRpcClient> newPerHostAndMethodDecorator(BiFunction<String, String, ? extends CircuitBreaker> factory,
                                 CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent); static CircuitBreakerRpcClientBuilder builder(
            CircuitBreakerRuleWithContent<RpcResponse> ruleWithContent);  }
@Test void testSingletonDecorator() { final CircuitBreaker circuitBreaker = mock(CircuitBreaker.class); when(circuitBreaker.canRequest()).thenReturn(false); final int COUNT = 1; failFastInvocation(CircuitBreakerRpcClient.newDecorator(circuitBreaker, rule()), COUNT); verify(circuitBreaker, times(COUNT)).canRequest(); }