Search in sources :

Example 16 with ServiceInfo

use of com.tencent.polaris.api.pojo.ServiceInfo 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();
}
Also used : ServiceInfo(com.tencent.polaris.api.pojo.ServiceInfo) ProcessRoutersResponse(com.tencent.polaris.router.api.rpc.ProcessRoutersResponse) ProcessRoutersRequest(com.tencent.polaris.router.api.rpc.ProcessRoutersRequest) ServiceKey(com.tencent.polaris.api.pojo.ServiceKey) DefaultServiceInstances(com.tencent.polaris.api.pojo.DefaultServiceInstances)

Aggregations

ServiceInfo (com.tencent.polaris.api.pojo.ServiceInfo)16 InstancesResponse (com.tencent.polaris.api.rpc.InstancesResponse)5 ProcessRoutersRequest (com.tencent.polaris.router.api.rpc.ProcessRoutersRequest)5 ArrayList (java.util.ArrayList)5 ServiceInstances (com.tencent.polaris.api.pojo.ServiceInstances)4 GetInstancesRequest (com.tencent.polaris.api.rpc.GetInstancesRequest)4 ProcessRoutersResponse (com.tencent.polaris.router.api.rpc.ProcessRoutersResponse)4 HashMap (java.util.HashMap)4 PolarisAgentProperties (cn.polarismesh.agent.core.spring.cloud.context.PolarisAgentProperties)3 ConsumerAPI (com.tencent.polaris.api.core.ConsumerAPI)3 DefaultInstance (com.tencent.polaris.api.pojo.DefaultInstance)3 ServiceKey (com.tencent.polaris.api.pojo.ServiceKey)3 DefaultServiceInstances (com.tencent.polaris.api.pojo.DefaultServiceInstances)2 Instance (com.tencent.polaris.api.pojo.Instance)2 ServiceEventKey (com.tencent.polaris.api.pojo.ServiceEventKey)2 Services (com.tencent.polaris.api.pojo.Services)2 ServicesByProto (com.tencent.polaris.client.pojo.ServicesByProto)2 Test (org.junit.Test)2 PolarisServiceInstance (cn.polarismesh.agent.core.spring.cloud.discovery.PolarisServiceInstance)1 ConsulException (com.ecwid.consul.ConsulException)1