Package io.grpc.stub

Class ClientCalls.CallToStreamObserverAdapter<ReqT>

    • Field Detail

      • frozen

        private boolean frozen
      • streamingResponse

        private final boolean streamingResponse
      • onReadyHandler

        private java.lang.Runnable onReadyHandler
      • initialRequest

        private int initialRequest
      • autoRequestEnabled

        private boolean autoRequestEnabled
      • aborted

        private boolean aborted
      • completed

        private boolean completed
    • Constructor Detail

      • CallToStreamObserverAdapter

        CallToStreamObserverAdapter​(ClientCall<ReqT,​?> call,
                                    boolean streamingResponse)
    • Method Detail

      • freeze

        private void freeze()
      • onNext

        public void onNext​(ReqT value)
        Description copied from interface: StreamObserver
        Receives a value from the stream.

        Can be called many times but is never called after StreamObserver.onError(Throwable) or StreamObserver.onCompleted() are called.

        Unary calls must invoke onNext at most once. Clients may invoke onNext at most once for server streaming calls, but may receive many onNext callbacks. Servers may invoke onNext at most once for client streaming calls, but may receive many onNext callbacks.

        If an exception is thrown by an implementation the caller is expected to terminate the stream by calling StreamObserver.onError(Throwable) with the caught exception prior to propagating it.

        Parameters:
        value - the value passed to the stream
      • onError

        public void onError​(java.lang.Throwable t)
        Description copied from interface: StreamObserver
        Receives a terminating error from the stream.

        May only be called once and if called it must be the last method called. In particular if an exception is thrown by an implementation of onError no further calls to any method are allowed.

        t should be a StatusException or StatusRuntimeException, but other Throwable types are possible. Callers should generally convert from a Status via Status.asException() or Status.asRuntimeException(). Implementations should generally convert to a Status via Status.fromThrowable(Throwable).

        Parameters:
        t - the error occurred on the stream
      • onCompleted

        public void onCompleted()
        Description copied from interface: StreamObserver
        Receives a notification of successful stream completion.

        May only be called once and if called it must be the last method called. In particular if an exception is thrown by an implementation of onCompleted no further calls to any method are allowed.

      • setOnReadyHandler

        public void setOnReadyHandler​(java.lang.Runnable onReadyHandler)
        Description copied from class: ClientCallStreamObserver
        Set a Runnable that will be executed every time the stream ClientCallStreamObserver.isReady() state changes from false to true. While it is not guaranteed that the same thread will always be used to execute the Runnable, it is guaranteed that executions are serialized with calls to the 'inbound' StreamObserver.

        May only be called during ClientResponseObserver.beforeStart(io.grpc.stub.ClientCallStreamObserver<ReqT>).

        Because there is a processing delay to deliver this notification, it is possible for concurrent writes to cause isReady() == false within this callback. Handle "spurious" notifications by checking isReady()'s current value instead of assuming it is now true. If isReady() == false the normal expectations apply, so there would be another onReadyHandler callback.

        Specified by:
        setOnReadyHandler in class ClientCallStreamObserver<ReqT>
        Parameters:
        onReadyHandler - to call when peer is ready to receive more messages.
      • request

        public void request​(int count)
        Description copied from class: ClientCallStreamObserver
        Requests the peer to produce count more messages to be delivered to the 'inbound' StreamObserver.

        This method is safe to call from multiple threads without external synchronization.

        Specified by:
        request in class ClientCallStreamObserver<ReqT>
        Parameters:
        count - more messages
      • cancel

        public void cancel​(@Nullable
                           java.lang.String message,
                           @Nullable
                           java.lang.Throwable cause)
        Description copied from class: ClientCallStreamObserver
        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.

        Specified by:
        cancel in class ClientCallStreamObserver<ReqT>
        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