Package io.grpc.stub

Interface ClientResponseObserver<ReqT,​RespT>

  • All Superinterfaces:
    StreamObserver<RespT>

    @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4693")
    public interface ClientResponseObserver<ReqT,​RespT>
    extends StreamObserver<RespT>
    Specialization of StreamObserver implemented by clients in order to interact with the advanced features of a call such as flow-control.
    • Method Detail

      • beforeStart

        void beforeStart​(ClientCallStreamObserver<ReqT> requestStream)
        Called by the runtime priot to the start of a call to provide a reference to the ClientCallStreamObserver for the outbound stream. This can be used to listen to onReady events, disable auto inbound flow and perform other advanced functions.

        Only the methods CallStreamObserver.setOnReadyHandler(Runnable) and CallStreamObserver.disableAutoInboundFlowControl() may be called within this callback

           // Copy an iterator to the request stream under flow-control
           someStub.fullDuplexCall(new ClientResponseObserver<ReqT, RespT>() {
             public void beforeStart(final ClientCallStreamObserver<Req> requestStream) {
               StreamObservers.copyWithFlowControl(someIterator, requestStream);
           });