1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

fix(nacos): support group

add search instance by group
This commit is contained in:
抱紧我的小鲤鱼 2020-05-26 11:22:54 +08:00 committed by GitHub
parent 213bf2a912
commit eff43225d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,12 +51,13 @@ public class NacosRule extends AbstractLoadBalancerRule {
public Server choose(Object key) {
try {
String clusterName = this.nacosDiscoveryProperties.getClusterName();
String group = this.nacosDiscoveryProperties.getGroup();
DynamicServerListLoadBalancer loadBalancer = (DynamicServerListLoadBalancer) getLoadBalancer();
String name = loadBalancer.getName();
NamingService namingService = nacosDiscoveryProperties
.namingServiceInstance();
List<Instance> instances = namingService.selectInstances(name, true);
List<Instance> instances = namingService.selectInstances(name, group, true);
if (CollectionUtils.isEmpty(instances)) {
LOGGER.warn("no instance in service {}", name);
return null;