优化灰度预发布

2.x
tanghc 5 years ago
parent c1849bcaf3
commit 6b505dfd8d
  1. 6
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/loadbalancer/BaseServerChooser.java

@ -53,7 +53,7 @@ public abstract class BaseServerChooser extends ZoneAvoidanceRule {
ILoadBalancer lb = getLoadBalancer(); ILoadBalancer lb = getLoadBalancer();
// 获取服务实例列表 // 获取服务实例列表
List<Server> servers = lb.getReachableServers(); List<Server> servers = lb.getReachableServers();
HttpServletRequest request = RequestContext.getCurrentContext().getRequest(); RequestContext currentContext = RequestContext.getCurrentContext();
// 存放预发服务器 // 存放预发服务器
List<Server> preServers = new ArrayList<>(4); List<Server> preServers = new ArrayList<>(4);
// 存放灰度发布服务器 // 存放灰度发布服务器
@ -77,11 +77,11 @@ public abstract class BaseServerChooser extends ZoneAvoidanceRule {
return super.choose(key); return super.choose(key);
} }
// 如果是从预发布域名访问过来,则认为是预发布请求 // 如果是从预发布域名访问过来,则认为是预发布请求
if (this.isRequestFromPreDomain(request)) { if (this.isRequestFromPreDomain(currentContext.getRequest())) {
return doChoose(preServers, key); return doChoose(preServers, key);
} }
// 如果是灰度请求 // 如果是灰度请求
if (this.isRequestGrayServer(RequestContext.getCurrentContext())) { if (this.isRequestGrayServer(currentContext)) {
return doChoose(grayServers, key); return doChoose(grayServers, key);
} }

Loading…
Cancel
Save