use of io.servicetalk.health.v1.HealthCheckResponse in project client-java by tikv.
the class AbstractGRPCClient method checkHealth.
protected boolean checkHealth(String addressStr, HostMapping hostMapping) {
ManagedChannel channel = channelFactory.getChannel(addressStr, hostMapping);
HealthGrpc.HealthBlockingStub stub = HealthGrpc.newBlockingStub(channel).withDeadlineAfter(getTimeout(), TimeUnit.MILLISECONDS);
HealthCheckRequest req = HealthCheckRequest.newBuilder().build();
try {
HealthCheckResponse resp = stub.check(req);
if (resp.getStatus() != HealthCheckResponse.ServingStatus.SERVING) {
return false;
}
} catch (Exception e) {
return false;
}
return true;
}
use of io.servicetalk.health.v1.HealthCheckResponse in project zeebe by camunda.
the class GatewayGrpcHealthIT method shouldReturnServingStatusWhenGatewayIsStarted.
@ParameterizedTest
@ValueSource(strings = { GatewayGrpc.SERVICE_NAME, HealthStatusManager.SERVICE_NAME_ALL_SERVICES })
void shouldReturnServingStatusWhenGatewayIsStarted(final String serviceName) {
// given
final ManagedChannel channel = NettyChannelBuilder.forTarget(zeebeGatewayContainer.getExternalGatewayAddress()).usePlaintext().build();
final HealthCheckResponse response;
// when
try {
final var client = HealthGrpc.newBlockingStub(channel);
response = client.check(HealthCheckRequest.newBuilder().setService(serviceName).build());
} finally {
channel.shutdownNow();
}
// then
assertThat(response.getStatus()).isEqualTo(ServingStatus.SERVING);
}
use of io.servicetalk.health.v1.HealthCheckResponse in project grpc-spring-boot-starter by yidongnan.
the class GrpcHealthServiceDefaultAutoConfigurationTest method checkResult.
void checkResult(final AwaitableStreamObserver<HealthCheckResponse> resultObserver) {
final HealthCheckResponse response = assertDoesNotThrow(resultObserver::getSingle);
assertEquals(ServingStatus.SERVING, response.getStatus());
}
use of io.servicetalk.health.v1.HealthCheckResponse in project helidon by oracle.
the class HealthServiceImplTest method shouldRequestCheckForUnknownService.
@Test
public void shouldRequestCheckForUnknownService() {
HealthServiceImpl healthService = HealthServiceImpl.create();
String serviceName = "unknown";
HealthCheckRequest request = HealthCheckRequest.newBuilder().setService(serviceName).build();
TestStreamObserver<HealthCheckResponse> observer = new TestStreamObserver<>();
healthService.check(request, observer);
assertThat(observer.awaitTerminalEvent(), is(true));
observer.assertError(this::isNotFoundError);
}
use of io.servicetalk.health.v1.HealthCheckResponse in project helidon by oracle.
the class HealthServiceImplTest method shouldRequestCheckForUpService.
@Test
public void shouldRequestCheckForUpService() {
HealthServiceImpl healthService = HealthServiceImpl.create();
String serviceName = "foo";
HealthCheck check = ConstantHealthCheck.up(serviceName);
HealthCheckRequest request = HealthCheckRequest.newBuilder().setService(serviceName).build();
TestStreamObserver<HealthCheckResponse> observer = new TestStreamObserver<>();
healthService.add(serviceName, check);
healthService.check(request, observer);
assertThat(observer.awaitTerminalEvent(), is(true));
observer.assertComplete().assertNoErrors().assertValueCount(1);
List<HealthCheckResponse> responses = observer.values();
assertThat(responses.size(), is(1));
HealthCheckResponse response = responses.get(0);
assertThat(response.getStatus(), is(HealthCheckResponse.ServingStatus.SERVING));
}
Aggregations