|
|
@ -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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|