Search in sources :

Example 1 with GetServicesRequest

use of com.tencent.polaris.api.rpc.GetServicesRequest in project polaris-java by polarismesh.

the class GetServicesExample method main.

public static void main(String[] args) throws Exception {
    InitResult initResult = ExampleUtils.initConsumerConfiguration(args, true);
    String namespace = initResult.getNamespace();
    try (ConsumerAPI consumerAPI = ExampleUtils.createConsumerAPI(initResult.getConfig())) {
        System.out.println("namespace " + namespace);
        GetServicesRequest request = new GetServicesRequest();
        request.setNamespace(namespace);
        ServicesResponse response = consumerAPI.getServices(request);
        List<ServiceInfo> services = response.getServices();
        System.out.println("services count is " + services.size());
        System.out.println("print all service " + services);
        request = new GetServicesRequest();
        request.setNamespace(namespace);
        response = consumerAPI.getServices(request);
        services = response.getServices();
        System.out.println("services count is " + services.size());
        System.out.println("print all service " + services);
    }
}
Also used : ServiceInfo(com.tencent.polaris.api.pojo.ServiceInfo) InitResult(com.tencent.polaris.discovery.example.utils.ExampleUtils.InitResult) ServicesResponse(com.tencent.polaris.api.rpc.ServicesResponse) ConsumerAPI(com.tencent.polaris.api.core.ConsumerAPI) GetServicesRequest(com.tencent.polaris.api.rpc.GetServicesRequest)

Example 2 with GetServicesRequest

use of com.tencent.polaris.api.rpc.GetServicesRequest in project spring-cloud-tencent by Tencent.

the class PolarisDiscoveryHandler method GetServices.

/**
 * Return all service for given namespace.
 * @return service list
 */
public ServicesResponse GetServices() {
    String namespace = polarisDiscoveryProperties.getNamespace();
    GetServicesRequest request = new GetServicesRequest();
    request.setNamespace(namespace);
    return polarisConsumer.getServices(request);
}
Also used : GetServicesRequest(com.tencent.polaris.api.rpc.GetServicesRequest)

Aggregations

GetServicesRequest (com.tencent.polaris.api.rpc.GetServicesRequest)2 ConsumerAPI (com.tencent.polaris.api.core.ConsumerAPI)1 ServiceInfo (com.tencent.polaris.api.pojo.ServiceInfo)1 ServicesResponse (com.tencent.polaris.api.rpc.ServicesResponse)1 InitResult (com.tencent.polaris.discovery.example.utils.ExampleUtils.InitResult)1