Search in sources :

Example 1 with PolarisServiceInstance

use of com.tencent.cloud.common.pojo.PolarisServiceInstance in project spring-cloud-tencent by Tencent.

the class PolarisServiceDiscovery method getInstances.

/**
 * Return all instances for the given service.
 * @param serviceId id of service
 * @return list of instances
 * @throws PolarisException polarisException
 */
public List<ServiceInstance> getInstances(String serviceId) throws PolarisException {
    List<ServiceInstance> instances = new ArrayList<>();
    InstancesResponse filteredInstances = polarisDiscoveryHandler.getHealthyInstances(serviceId);
    ServiceInstances serviceInstances = filteredInstances.toServiceInstances();
    for (Instance instance : serviceInstances.getInstances()) {
        instances.add(new PolarisServiceInstance(instance));
    }
    return instances;
}
Also used : ServiceInstances(com.tencent.polaris.api.pojo.ServiceInstances) PolarisServiceInstance(com.tencent.cloud.common.pojo.PolarisServiceInstance) ServiceInstance(org.springframework.cloud.client.ServiceInstance) Instance(com.tencent.polaris.api.pojo.Instance) ArrayList(java.util.ArrayList) PolarisServiceInstance(com.tencent.cloud.common.pojo.PolarisServiceInstance) ServiceInstance(org.springframework.cloud.client.ServiceInstance) InstancesResponse(com.tencent.polaris.api.rpc.InstancesResponse) PolarisServiceInstance(com.tencent.cloud.common.pojo.PolarisServiceInstance)

Aggregations

PolarisServiceInstance (com.tencent.cloud.common.pojo.PolarisServiceInstance)1 Instance (com.tencent.polaris.api.pojo.Instance)1 ServiceInstances (com.tencent.polaris.api.pojo.ServiceInstances)1 InstancesResponse (com.tencent.polaris.api.rpc.InstancesResponse)1 ArrayList (java.util.ArrayList)1 ServiceInstance (org.springframework.cloud.client.ServiceInstance)1