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:
parent
213bf2a912
commit
eff43225d6
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user