/** Asks the remote server to list its services and completes when the server responds. */ public ListenableFuture<ImmutableList<String>> listServices() { ListServicesHandler rpcHandler = new ListServicesHandler(); StreamObserver<ServerReflectionRequest> requestStream = ServerReflectionGrpc.newStub(channel) .withDeadlineAfter(LIST_RPC_DEADLINE_MS, TimeUnit.MILLISECONDS) .serverReflectionInfo(rpcHandler); return rpcHandler.start(requestStream); }
/** * Returns a {@link FileDescriptorSet} containing all the transitive dependencies of the supplied * service, as provided by the remote server. */ public ListenableFuture<FileDescriptorSet> lookupService(String serviceName) { LookupServiceHandler rpcHandler = new LookupServiceHandler(serviceName); StreamObserver<ServerReflectionRequest> requestStream = ServerReflectionGrpc.newStub(channel) .withDeadlineAfter(LOOKUP_RPC_DEADLINE_MS, TimeUnit.MILLISECONDS) .serverReflectionInfo(rpcHandler); return rpcHandler.start(requestStream); }
@Before public void setUp() throws Exception { reflectionService = ProtoReflectionService.newInstance(); server = InProcessServerBuilder.forName("proto-reflection-test") .directExecutor() .addService(reflectionService) .addService(new ReflectableServiceGrpc.ReflectableServiceImplBase() {}) .fallbackHandlerRegistry(handlerRegistry) .build() .start(); channel = InProcessChannelBuilder.forName("proto-reflection-test").directExecutor().build(); stub = ServerReflectionGrpc.newStub(channel); }