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

下面列出了怎么用io.grpc.health.v1.HealthGrpc的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: conductor   文件: GRPCServerProvider.java
@Inject
public GRPCServerProvider(
        GRPCServerConfiguration grpcServerConfiguration,
        HealthGrpc.HealthImplBase healthServiceImpl,
        EventServiceGrpc.EventServiceImplBase eventServiceImpl,
        MetadataServiceGrpc.MetadataServiceImplBase metadataServiceImpl,
        TaskServiceGrpc.TaskServiceImplBase taskServiceImpl,
        WorkflowServiceGrpc.WorkflowServiceImplBase workflowServiceImpl
) {
    this.configuration = grpcServerConfiguration;
    this.healthServiceImpl = healthServiceImpl;

    this.eventServiceImpl = eventServiceImpl;
    this.metadataServiceImpl = metadataServiceImpl;
    this.taskServiceImpl = taskServiceImpl;
    this.workflowServiceImpl = workflowServiceImpl;
}
 
源代码2 项目: conductor   文件: HealthServiceImplTest.java
@Test
public void healthServing() throws Exception {
    // Generate a unique in-process server name.
    String serverName = InProcessServerBuilder.generateName();
    HealthCheckAggregator hca = mock(HealthCheckAggregator.class);
    CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class);
    HealthCheckStatus hcs = mock(HealthCheckStatus.class);
    when(hcs.isHealthy()).thenReturn(true);
    when(hcsf.get()).thenReturn(hcs);
    when(hca.check()).thenReturn(hcsf);
    HealthServiceImpl healthyService = new HealthServiceImpl(hca);

    addService(serverName, healthyService);
    HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub(
            // Create a client channel and register for automatic graceful shutdown.
            grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()));


    HealthCheckResponse reply = blockingStub.check(HealthCheckRequest.newBuilder().build());

    assertEquals(HealthCheckResponse.ServingStatus.SERVING, reply.getStatus());
}
 
源代码3 项目: conductor   文件: HealthServiceImplTest.java
@Test
public void healthNotServing() throws Exception {
    // Generate a unique in-process server name.
    String serverName = InProcessServerBuilder.generateName();
    HealthCheckAggregator hca = mock(HealthCheckAggregator.class);
    CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class);
    HealthCheckStatus hcs = mock(HealthCheckStatus.class);
    when(hcs.isHealthy()).thenReturn(false);
    when(hcsf.get()).thenReturn(hcs);
    when(hca.check()).thenReturn(hcsf);
    HealthServiceImpl healthyService = new HealthServiceImpl(hca);

    addService(serverName, healthyService);
    HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub(
            // Create a client channel and register for automatic graceful shutdown.
            grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()));


    HealthCheckResponse reply = blockingStub.check(HealthCheckRequest.newBuilder().build());

    assertEquals(HealthCheckResponse.ServingStatus.NOT_SERVING, reply.getStatus());
}
 
源代码4 项目: conductor   文件: HealthServiceImplTest.java
@Test
public void healthException() throws Exception {
    // Generate a unique in-process server name.
    String serverName = InProcessServerBuilder.generateName();
    HealthCheckAggregator hca = mock(HealthCheckAggregator.class);
    CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class);
    when(hcsf.get()).thenThrow(InterruptedException.class);
    when(hca.check()).thenReturn(hcsf);
    HealthServiceImpl healthyService = new HealthServiceImpl(hca);

    addService(serverName, healthyService);
    HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub(
            // Create a client channel and register for automatic graceful shutdown.
            grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()));

    thrown.expect(StatusRuntimeException.class);
    thrown.expect(hasProperty("status", is(Status.INTERNAL)));
    blockingStub.check(HealthCheckRequest.newBuilder().build());

}
 
源代码5 项目: grpc-nebula-java   文件: HealthCheckClient.java
public HealthCheckClient() {
  String target = "zookeeper:///grpc.health.v1.Health";

  channel = ManagedChannelBuilder.forTarget(target)
          .usePlaintext()
          .build();

  blockingStub = HealthGrpc.newBlockingStub(channel);
}
 
源代码6 项目: hedera-mirror-node   文件: GrpcHealthIndicator.java
@Override
public Health health() {
    HealthGrpc.HealthImplBase healthService = (HealthGrpc.HealthImplBase) healthStatusManager
            .getHealthService();
    HealthCheckRequest healthcheckRequest = HealthCheckRequest.newBuilder().setService(serviceName).build();
    HealthStreamObserver healthStreamObserver = new HealthStreamObserver();
    healthService.check(healthcheckRequest, healthStreamObserver);
    return healthStreamObserver.getHealth();
}
 
源代码7 项目: microbean-helm   文件: Tiller.java
public HealthBlockingStub getHealthBlockingStub() {
  HealthBlockingStub returnValue = null;
  if (this.channel != null) {
    returnValue = MetadataUtils.attachHeaders(HealthGrpc.newBlockingStub(this.channel), metadata);
  }
  return returnValue;
}
 
源代码8 项目: microbean-helm   文件: Tiller.java
public HealthFutureStub getHealthFutureStub() {
  HealthFutureStub returnValue = null;
  if (this.channel != null) {
    returnValue = MetadataUtils.attachHeaders(HealthGrpc.newFutureStub(this.channel), metadata);
  }
  return returnValue;
}
 
源代码9 项目: microbean-helm   文件: Tiller.java
public HealthStub getHealthStub() {
  HealthStub returnValue = null;
  if (this.channel != null) {
    returnValue = MetadataUtils.attachHeaders(HealthGrpc.newStub(this.channel), metadata);
  }
  return returnValue;
}
 
源代码10 项目: conductor   文件: GRPCModule.java
@Override
protected void configure() {

    bind(HealthGrpc.HealthImplBase.class).to(HealthServiceImpl.class);

    bind(EventServiceGrpc.EventServiceImplBase.class).to(EventServiceImpl.class);
    bind(MetadataServiceGrpc.MetadataServiceImplBase.class).to(MetadataServiceImpl.class);
    bind(TaskServiceGrpc.TaskServiceImplBase.class).to(TaskServiceImpl.class);
    bind(WorkflowServiceGrpc.WorkflowServiceImplBase.class).to(WorkflowServiceImpl.class);

    bind(GRPCServerConfiguration.class).to(GRPCServerSystemConfiguration.class);
    bind(GRPCServerProvider.class);
}
 
源代码11 项目: 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);
}
 
HcStream() {
  callCreationNanos = time.currentTimeNanos();
  callServiceName = serviceName;
  call = subchannel.asChannel().newCall(HealthGrpc.getWatchMethod(), CallOptions.DEFAULT);
}
 
源代码13 项目: grpc-nebula-java   文件: HealthStatusManagerTest.java
@Before
public void setup() {
  grpcServerRule.getServiceRegistry().addService(service);
  stub = HealthGrpc.newStub(grpcServerRule.getChannel());
  blockingStub = HealthGrpc.newBlockingStub(grpcServerRule.getChannel());
}
 
HcStream() {
  stopwatch = stopwatchSupplier.get().start();
  callServiceName = serviceName;
  call = subchannel.asChannel().newCall(HealthGrpc.getWatchMethod(), CallOptions.DEFAULT);
}
 
源代码15 项目: grpc-java   文件: HealthStatusManagerTest.java
@Before
public void setup() {
  grpcServerRule.getServiceRegistry().addService(service);
  stub = HealthGrpc.newStub(grpcServerRule.getChannel());
  blockingStub = HealthGrpc.newBlockingStub(grpcServerRule.getChannel());
}
 
 类所在包
 类方法
 同包方法