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

2
.gitignore vendored

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

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

Loading…
Cancel
Save