From 6da178d47f0a04e455ef6e8ba9106b2e89912b07 Mon Sep 17 00:00:00 2001 From: chentianming Date: Thu, 26 May 2022 10:26:58 +0800 Subject: [PATCH] README.md --- README.md | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index cba0ead..8ecf44c 100644 --- a/README.md +++ b/README.md @@ -544,27 +544,21 @@ retrofit: ```java -@Slf4j @Component -public class CustomSourceOkHttpClientRegistrar implements SourceOkHttpClientRegistrar { +public class CustomCircuitBreakerConfigRegistrar implements CircuitBreakerConfigRegistrar { @Override - public void register(SourceOkHttpClientRegistry registry) { + public void register(CircuitBreakerConfigRegistry registry) { - // 替换默认的SourceOkHttpClient - registry.register(Constants.DEFAULT_SOURCE_OK_HTTP_CLIENT, new OkHttpClient.Builder() - .addInterceptor(chain -> { - log.info("============替换默认的SourceOkHttpClient============="); - return chain.proceed(chain.request()); - }) - .build()); + // 替换默认的CircuitBreakerConfig + registry.register(Constants.DEFAULT_CIRCUIT_BREAKER_CONFIG, CircuitBreakerConfig.ofDefaults()); - // 添加新的SourceOkHttpClient - registry.register("testSourceOkHttpClient", new OkHttpClient.Builder() - .addInterceptor(chain -> { - log.info("============使用testSourceOkHttpClient============="); - return chain.proceed(chain.request()); - }) + // 注册其它的CircuitBreakerConfig + registry.register("testCircuitBreakerConfig", CircuitBreakerConfig.custom() + .slidingWindowType(CircuitBreakerConfig.SlidingWindowType.TIME_BASED) + .failureRateThreshold(20) + .minimumNumberOfCalls(5) + .permittedNumberOfCallsInHalfOpenState(5) .build()); } }