Closed loongs-zhang closed 2 years ago
Oh, maybe it's better to refactor like DividePlugin ?
发自我的iPhone
------------------ Original ------------------
From: dragon-zhang @.>
Date: Mon,Feb 21,2022 5:45 PM
To: apache/incubator-shenyu @.>
Cc: dragon-zhang @.>, Your activity @.>
Subject: Re: [apache/incubator-shenyu] [Question] How about change ribbon ServerListRefreshInterval
from 30s to 10s ? (Issue #2916)
Question
If the data of the registry (such as zookeeper) has been updated, SpringCloudPlugin will still select unavailable instances when using Ribbon for load balancing, change ServerListRefreshInterval from 30s to 10s can't completely solve this problem, but it can be avoided to a great extent.
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.Message ID: @.***>
this props,maybe can dynamic config~
In ShenyuClientRegisterSpringCloudServiceImpl#buildHandle
, I found that divideUpstreams
has been set in the handle
field of the selector
, which means that we can do this directly in SpringCloudPlugin#doExecute
:
@Override
protected Mono<Void> doExecute(final ServerWebExchange exchange, final ShenyuPluginChain chain, final SelectorData selector,
final RuleData rule) {
if (Objects.isNull(rule)) {
return Mono.empty();
}
final ShenyuContext shenyuContext = exchange.getAttribute(Constants.CONTEXT);
assert shenyuContext != null;
final SpringCloudSelectorHandle springCloudSelectorHandle = SpringCloudPluginDataHandler.SELECTOR_CACHED.get().obtainHandle(selector.getId());
final SpringCloudRuleHandle ruleHandle = SpringCloudPluginDataHandler.RULE_CACHED.get().obtainHandle(CacheKeyUtils.INST.getKey(rule));
//Below is a partial implementation of the code I plan to refactor
List<Upstream> upstreamList = UpstreamCacheManager.getInstance().findUpstreamListBySelectorId(selector.getId());
//......
}
In this way, another benefit is that we don't have to depend on Ribbon
.
In
ShenyuClientRegisterSpringCloudServiceImpl#buildHandle
, I found thatdivideUpstreams
has been set in thehandle
field of theselector
, which means that we can do this directly inSpringCloudPlugin#doExecute
:@Override protected Mono<Void> doExecute(final ServerWebExchange exchange, final ShenyuPluginChain chain, final SelectorData selector, final RuleData rule) { if (Objects.isNull(rule)) { return Mono.empty(); } final ShenyuContext shenyuContext = exchange.getAttribute(Constants.CONTEXT); assert shenyuContext != null; final SpringCloudSelectorHandle springCloudSelectorHandle = SpringCloudPluginDataHandler.SELECTOR_CACHED.get().obtainHandle(selector.getId()); final SpringCloudRuleHandle ruleHandle = SpringCloudPluginDataHandler.RULE_CACHED.get().obtainHandle(CacheKeyUtils.INST.getKey(rule)); //Below is a partial implementation of the code I plan to refactor List<Upstream> upstreamList = UpstreamCacheManager.getInstance().findUpstreamListBySelectorId(selector.getId()); //...... }
Haha, as I supposed :)
this props,maybe can dynamic config~
I think List<Upstream> upstreamList = UpstreamCacheManager.getInstance().findUpstreamListBySelectorId(selector.getId());
could be better, what do you think ?
good pr, i will close this issue~
Question
If the data of the registry (such as zookeeper) has been updated,
SpringCloudPlugin
will still selectunavailable
instances when usingRibbon
for load balancing, changeServerListRefreshInterval
from30s
to10s
can't completely solve this problem, but it can be avoided to a great extent.