use of com.tencent.polaris.api.pojo.DefaultServiceInstances in project polaris-java-agent by polarismesh.
the class PolarisOperator method route.
public List<Instance> route(String service, String method, Map<String, String> labels, List<Instance> instances) {
ServiceKey serviceKey = new ServiceKey(polarisConfig.getNamespace(), service);
DefaultServiceInstances defaultServiceInstances = new DefaultServiceInstances(serviceKey, instances);
ServiceInfo serviceInfo = null;
if (null != labels && labels.size() > 0) {
serviceInfo = new ServiceInfo();
serviceInfo.setMetadata(labels);
}
ProcessRoutersRequest request = new ProcessRoutersRequest();
request.setDstInstances(defaultServiceInstances);
request.setMethod(method);
request.setSourceService(serviceInfo);
ProcessRoutersResponse processRoutersResponse = routerAPI.processRouters(request);
return processRoutersResponse.getServiceInstances().getInstances();
}
Aggregations