Java 类io.grpc.health.v1.HealthGrpc 实例源码

项目:grpc-spring-boot-starter    文件:DemoAppTest.java   
@Test
public void testHealthCheck() throws ExecutionException, InterruptedException {
    final HealthCheckRequest healthCheckRequest = HealthCheckRequest.newBuilder().setService(GreeterGrpc.getServiceDescriptor().getName()).build();
    final HealthGrpc.HealthFutureStub healthFutureStub = HealthGrpc.newFutureStub(channel);
    final HealthCheckResponse.ServingStatus servingStatus = healthFutureStub.check(healthCheckRequest).get().getStatus();
    assertNotNull(servingStatus);
    assertEquals(servingStatus, HealthCheckResponse.ServingStatus.SERVING);
}