final class Default implements SetterFactory {
@Override
public HystrixCommand.Setter create(Target<?> target, Method method) {
String groupKey = target.name();
// 在這裏生產HystrixCommonKey
String commandKey = Feign.configKey(target.type(), method);
return HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
}
}複製代碼
hystrix:
threadpool:
default:
# 核心線程池大小 默認10
coreSize: 20
# 最大最大線程池大小
maximumSize: 30
# 此屬性容許maximumSize的配置生效。 那麼該值能夠等於或高於coreSize。 設置coreSize <maximumSize會建立一個線程池,該線程池能夠支持maximumSize併發,但在相對不活動期間將向系統返回線程。 (以keepAliveTimeInMinutes爲準)
allowMaximumSizeToDivergeFromCoreSize: true
# 請求等待隊列
maxQueueSize: 10
# 隊列大小拒絕閥值 在還未超過請求等待隊列時也會拒絕的大小
queueSizeRejectionThreshold: 10
command:
LimitCheckApi#rcsLimitCheck(RpcRequest): #default全局有效 默認值爲 commonKey commonKey生成方法在 Feign.configKey(target.type(), method) 中
fallback:
enabled: true
execution:
timeout:
#若是enabled設置爲false,則請求超時交給ribbon控制,爲true,則超時做爲熔斷根據
enabled: true
isolation:
#隔離策略,有THREAD和SEMAPHORE
#THREAD - 它在單獨的線程上執行,併發請求受線程池中的線程數量的限制
#SEMAPHORE - 它在調用線程上執行,併發請求受到信號量計數的限制
#對比:https://www.cnblogs.com/java-synchronized/p/7927726.html
thread:
timeoutInMilliseconds: 800 #斷路器超時時間,默認1000ms
LimitCheckApi#testTimeOutFallBack(long):
fallback:
enabled: true
execution:
timeout:
#若是enabled設置爲false,則請求超時交給ribbon控制,爲true,則超時做爲熔斷根據
enabled: true
isolation:
#隔離策略,有THREAD和SEMAPHORE
#THREAD - 它在單獨的線程上執行,併發請求受線程池中的線程數量的限制
#SEMAPHORE - 它在調用線程上執行,併發請求受到信號量計數的限制
#對比:https://www.cnblogs.com/java-synchronized/p/7927726.html
thread:
timeoutInMilliseconds: 800 #斷路器超時時間,默認1000ms
feign:
hystrix:
enabled: true複製代碼
歡迎加入做者的微信公衆號:html