Java 类io.grpc.protobuf.services.ProtoReflectionService 实例源码

项目:polyglot    文件:Main.java   
public static void main(String[] args) {
  logger.info("Starting grpc server on port: " + SERVER_PORT);
  try {
    ServerBuilder.forPort(SERVER_PORT)
        .addService(new HelloServiceImpl())
        .addService(ProtoReflectionService.newInstance())
        .build()
        .start()
        .awaitTermination();
  } catch (InterruptedException | IOException e) {
    logger.info("Caught exception, shutting down", e);
    System.exit(0);
  }
}
项目:polyglot    文件:TestServer.java   
/** Starts a grpc server on the given port, throws {@link IOException} on failure. */
private static Server tryStartServer(
    int port,
    TestServiceImplBase testService,
    Optional<SslContext> sslContext) throws IOException {
  NettyServerBuilder serverBuilder = NettyServerBuilder.forPort(port)
      .addService(testService)
      .addService(ProtoReflectionService.newInstance());
  if (sslContext.isPresent()) {
    serverBuilder.sslContext(sslContext.get());
  }
  return serverBuilder.build().start();
}
项目:ibole-microservice    文件:AbstractGrpcServer.java   
/**
 * Load gRPC specified service definition and then add to gRPC registry.
 * 
 * @param serverBuilder NettyServerBuilder
 * @return the instance of NettyServerBuilder
 */
@SuppressWarnings("unchecked")
protected T bindService(T serverBuilder) {

  List<ServiceDefinitionAdapter<?>> services = ServiceDefinitionLoader.loader().getServiceList();
  for (ServiceDefinitionAdapter<?> service : services) {
    serverBuilder
        .addService(ServerInterceptors.intercept((ServerServiceDefinition)service.getServiceDefinition(), adaptedInterceptors));
  }
  serverBuilder.addService(ProtoReflectionService.newInstance());
  return serverBuilder; 
}