pull/88/head
Nepxion 6 years ago
parent 13c2bcfe0f
commit 9373e79aff

2
.gitignore vendored

@ -1,5 +1,7 @@
# Compiled class file
*.class
*.classpath
*.factorypath
# Log file
*.log

@ -24,12 +24,12 @@ import org.springframework.cloud.client.discovery.DiscoveryClient;
import java.util.*;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
/**
* @author xiaojing
* @author renhaojun
*/
public class NacosDiscoveryClient implements DiscoveryClient {
@ -98,8 +98,4 @@ public class NacosDiscoveryClient implements DiscoveryClient {
return Collections.emptyList();
}
}
public NamingService getNamingService() {
return discoveryProperties.namingServiceInstance();
}
}

@ -19,7 +19,7 @@ package org.springframework.cloud.alibaba.nacos.ribbon;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.AbstractServerList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryClient;
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
import java.util.ArrayList;
import java.util.List;
@ -28,11 +28,12 @@ import com.alibaba.nacos.api.naming.pojo.Instance;
/**
* @author xiaojing
* @author renhaojun
*/
public class NacosServerList extends AbstractServerList<NacosServer> {
@Autowired
private NacosDiscoveryClient discoveryClient;
private NacosDiscoveryProperties discoveryProperties;
private String serviceId;
@ -55,7 +56,7 @@ public class NacosServerList extends AbstractServerList<NacosServer> {
private List<NacosServer> getServers() {
try {
List<Instance> instances = discoveryClient.getNamingService()
List<Instance> instances = discoveryProperties.namingServiceInstance()
.getAllInstances(serviceId);
return instancesToServerList(instances);
}

Loading…
Cancel
Save