@Test public void inprocessTransportManualFlow() throws Exception { final Semaphore semaphore = new Semaphore(1); ServerServiceDefinition service = ServerServiceDefinition.builder("some") .addMethod(STREAMING_METHOD, ServerCalls.asyncBidiStreamingCall( new ServerCalls.BidiStreamingMethod<Integer, Integer>() { int iteration; @Override public StreamObserver<Integer> invoke(StreamObserver<Integer> responseObserver) { final ServerCallStreamObserver<Integer> serverCallObserver = (ServerCallStreamObserver<Integer>) responseObserver; serverCallObserver.setOnReadyHandler(new Runnable() { @Override public void run() { while (serverCallObserver.isReady()) { serverCallObserver.onNext(iteration); } iteration++; semaphore.release(); } }); return new ServerCalls.NoopStreamObserver<Integer>() { @Override public void onCompleted() { serverCallObserver.onCompleted(); } }; } })) .build(); long tag = System.nanoTime(); InProcessServerBuilder.forName("go-with-the-flow" + tag).addService(service).build().start(); ManagedChannelImpl channel = InProcessChannelBuilder.forName("go-with-the-flow" + tag).build(); final ClientCall<Integer, Integer> clientCall = channel.newCall(STREAMING_METHOD, CallOptions.DEFAULT); final CountDownLatch latch = new CountDownLatch(1); final int[] receivedMessages = new int[6]; clientCall.start(new ClientCall.Listener<Integer>() { int index; @Override public void onMessage(Integer message) { receivedMessages[index++] = message; } @Override public void onClose(Status status, Metadata trailers) { latch.countDown(); } }, new Metadata()); semaphore.acquire(); clientCall.request(1); semaphore.acquire(); clientCall.request(2); semaphore.acquire(); clientCall.request(3); clientCall.halfClose(); latch.await(5, TimeUnit.SECONDS); assertArrayEquals(new int[]{0, 1, 1, 2, 2, 2}, receivedMessages); }
public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); }
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); } }
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); } private  ServerCalls(); }
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); } private  ServerCalls(); static ServerCallHandler<ReqT, RespT> asyncUnaryCall(
      final UnaryMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncServerStreamingCall(
      final ServerStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncClientStreamingCall(
      final ClientStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall(
      final BidiStreamingMethod<ReqT, RespT> method); static void asyncUnimplementedUnaryCall(MethodDescriptor<?, ?> methodDescriptor,
      StreamObserver<?> responseObserver); static StreamObserver<T> asyncUnimplementedStreamingCall(
      MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver); }
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); } private  ServerCalls(); static ServerCallHandler<ReqT, RespT> asyncUnaryCall(
      final UnaryMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncServerStreamingCall(
      final ServerStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncClientStreamingCall(
      final ClientStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall(
      final BidiStreamingMethod<ReqT, RespT> method); static void asyncUnimplementedUnaryCall(MethodDescriptor<?, ?> methodDescriptor,
      StreamObserver<?> responseObserver); static StreamObserver<T> asyncUnimplementedStreamingCall(
      MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver);  }