Package io.grpc.stub

Class ClientCallStreamObserver<V>

  • All Implemented Interfaces:
    StreamObserver<V>

    @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1788")
    public abstract class ClientCallStreamObserver<V>
    extends CallStreamObserver<V>
    A refinement of CallStreamObserver that allows for lower-level interaction with client calls.

    Like StreamObserver, implementations are not required to be thread-safe; if multiple threads will be writing to an instance concurrently, the application must synchronize its calls.

    DO NOT MOCK: The API is too complex to reliably mock. Use InProcessChannelBuilder to create "real" RPCs suitable for testing and make a fake for the server-side.

    • Constructor Detail

      • ClientCallStreamObserver

        public ClientCallStreamObserver()
    • Method Detail

      • cancel

        public abstract void cancel​(@Nullable
                                    java.lang.String message,
                                    @Nullable
                                    java.lang.Throwable cause)
        Prevent any further processing for this ClientCallStreamObserver. No further messages will be received. The server is informed of cancellations, but may not stop processing the call. Cancelling an already cancel()ed ClientCallStreamObserver has no effect.

        No other methods on this class can be called after this method has been called.

        It is recommended that at least one of the arguments to be non-null, to provide useful debug information. Both argument being null may log warnings and result in suboptimal performance. Also note that the provided information will not be sent to the server.

        Parameters:
        message - if not null, will appear as the description of the CANCELLED status
        cause - if not null, will appear as the cause of the CANCELLED status