use of com.tencent.polaris.api.rpc.ServicesResponse in project polaris-java by polarismesh.
the class GetServicesTest method testRoundTrip.
@Test
public void testRoundTrip() {
Configuration configuration = TestUtils.configWithEnvAddress();
try (ConsumerAPI consumerAPI = DiscoveryAPIFactory.createConsumerAPIByConfig(configuration)) {
for (int i = 0; i < 5; i++) {
namingServer.getNamingService().addService(new ServiceKey(NAMESPACE_TEST, "get_services_test_" + i));
}
ServicesResponse response = consumerAPI.getServices(GetServicesRequest.builder().namespace(NAMESPACE_TEST).build());
Assert.assertFalse(CollectionUtils.isEmpty(response.getServices()));
Assert.assertEquals(5, response.getServices().size());
}
}
use of com.tencent.polaris.api.rpc.ServicesResponse 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);
}
}
Aggregations