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

Merge pull request #1481 from nine-third-repo/master

[Optimize]: NacosRule support group
This commit is contained in:
Jim Fang 2020-07-13 11:54:22 +08:00 committed by GitHub
commit f6fb6890b9
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;