在上一篇文章中,体验到了soul
中hystrix
插件熔断的功能,今天来分析其中执行过程和相关原理。
在HystrixPlugin
插件中就是主要的核心处理逻辑:
protected Mono<Void> doExecute(final ServerWebExchange exchange, final SoulPluginChain chain, final SelectorData selector, final RuleData rule) {
//省略了其他代码
//构建command对象
Command command = fetchCommand(hystrixHandle, exchange, chain);
return Mono.create(s -> {
//执行具体请求
Subscription sub = command.fetchObservable().subscribe(s::success,
s::error, s::success);
s.onCancel(sub::unsubscribe);
//熔断器打开了
if (command.isCircuitBreakerOpen())