mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
update nacos discovery logic, support both health and enabled
This commit is contained in:
parent
51e9ae552a
commit
bee06af41c
@ -60,7 +60,7 @@ public class NacosDiscoveryClient implements DiscoveryClient {
|
||||
public List<ServiceInstance> getInstances(String serviceId) {
|
||||
try {
|
||||
List<Instance> instances = discoveryProperties.namingServiceInstance()
|
||||
.getAllInstances(serviceId);
|
||||
.selectInstances(serviceId, true);
|
||||
return hostToServiceInstanceList(instances, serviceId);
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -89,9 +89,7 @@ public class NacosDiscoveryClient implements DiscoveryClient {
|
||||
List<Instance> instances, String serviceId) {
|
||||
List<ServiceInstance> result = new ArrayList<ServiceInstance>(instances.size());
|
||||
for (Instance instance : instances) {
|
||||
if (instance.isHealthy()) {
|
||||
result.add(hostToServiceInstance(instance, serviceId));
|
||||
}
|
||||
result.add(hostToServiceInstance(instance, serviceId));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class NacosServerList extends AbstractServerList<NacosServer> {
|
||||
private List<NacosServer> getServers() {
|
||||
try {
|
||||
List<Instance> instances = discoveryProperties.namingServiceInstance()
|
||||
.getAllInstances(serviceId);
|
||||
.selectInstances(serviceId, true);
|
||||
return instancesToServerList(instances);
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -70,9 +70,7 @@ public class NacosServerList extends AbstractServerList<NacosServer> {
|
||||
private List<NacosServer> instancesToServerList(List<Instance> instances) {
|
||||
List<NacosServer> result = new ArrayList<>(instances.size());
|
||||
for (Instance instance : instances) {
|
||||
if (instance.isHealthy()) {
|
||||
result.add(new NacosServer(instance));
|
||||
}
|
||||
result.add(new NacosServer(instance));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user