Class NoopClientStream

java.lang.Object
io.grpc.internal.NoopClientStream
All Implemented Interfaces:
ClientStream, Stream
Direct Known Subclasses:
FailingClientStream

public class NoopClientStream extends Object implements ClientStream
An implementation of ClientStream that silently does nothing for the operations.
  • Field Details

  • Constructor Details

    • NoopClientStream

      public NoopClientStream()
  • Method Details

    • setAuthority

      public void setAuthority(String authority)
      Description copied from interface: ClientStream
      Override the default authority with authority. May only be called before ClientStream.start(io.grpc.internal.ClientStreamListener).
      Specified by:
      setAuthority in interface ClientStream
    • start

      public void start(ClientStreamListener listener)
      Description copied from interface: ClientStream
      Starts stream. This method may only be called once. It is safe to do latent initialization of the stream up until ClientStream.start(io.grpc.internal.ClientStreamListener) is called.

      This method should not throw any exceptions.

      Specified by:
      start in interface ClientStream
      Parameters:
      listener - non-null listener of stream events
    • getAttributes

      public Attributes getAttributes()
      Description copied from interface: ClientStream
      Attributes that the stream holds at the current moment. Thread-safe and can be called at any time, although some attributes are there only after a certain point.
      Specified by:
      getAttributes in interface ClientStream
    • request

      public void request(int numMessages)
      Description copied from interface: Stream
      Requests up to the given number of messages from the call to be delivered via StreamListener.messagesAvailable(StreamListener.MessageProducer). No additional messages will be delivered. If the stream has a start() method, it must be called before requesting messages.
      Specified by:
      request in interface Stream
      Parameters:
      numMessages - the requested number of messages to be delivered to the listener.
    • writeMessage

      public void writeMessage(InputStream message)
      Description copied from interface: Stream
      Writes a message payload to the remote end-point. The bytes from the stream are immediately read by the Transport. Where possible callers should use streams that are KnownLength to improve efficiency. This method will always return immediately and will not wait for the write to complete. If the stream has a start() method, it must be called before writing any messages.

      It is recommended that the caller consult Stream.isReady() before calling this method to avoid excessive buffering in the transport.

      This method takes ownership of the InputStream, and implementations are responsible for calling InputStream.close().

      Specified by:
      writeMessage in interface Stream
      Parameters:
      message - stream containing the serialized message to be sent
    • flush

      public void flush()
      Description copied from interface: Stream
      Flushes any internally buffered messages to the remote end-point.
      Specified by:
      flush in interface Stream
    • isReady

      public boolean isReady()
      Description copied from interface: Stream
      If true, indicates that the transport is capable of sending additional messages without requiring excessive buffering internally. Otherwise, StreamListener.onReady() will be called when it turns true.

      This is just a suggestion and the application is free to ignore it, however doing so may result in excessive buffering within the transport.

      Specified by:
      isReady in interface Stream
    • cancel

      public void cancel(Status status)
      Description copied from interface: ClientStream
      Abnormally terminates the stream. After calling this method, no further messages will be sent or received, however it may still be possible to receive buffered messages for a brief period until ClientStreamListener.closed(io.grpc.Status, io.grpc.internal.ClientStreamListener.RpcProgress, io.grpc.Metadata) is called. This method may only be called after ClientStream.start(io.grpc.internal.ClientStreamListener), but else is safe to be called at any time and multiple times and from any thread.
      Specified by:
      cancel in interface ClientStream
      Parameters:
      status - must be non-OK
    • halfClose

      public void halfClose()
      Description copied from interface: ClientStream
      Closes the local side of this stream and flushes any remaining messages. After this is called, no further messages may be sent on this stream, but additional messages may be received until the remote end-point is closed. This method may only be called once, and only after ClientStream.start(io.grpc.internal.ClientStreamListener).
      Specified by:
      halfClose in interface ClientStream
    • setMessageCompression

      public void setMessageCompression(boolean enable)
      Description copied from interface: Stream
      Enables per-message compression, if an encoding type has been negotiated. If no message encoding has been negotiated, this is a no-op. By default per-message compression is enabled, but may not have any effect if compression is not enabled on the call.
      Specified by:
      setMessageCompression in interface Stream
    • optimizeForDirectExecutor

      public void optimizeForDirectExecutor()
      Description copied from interface: Stream
      Provides a hint that directExecutor is being used by the listener for callbacks to the application. No action is required. There is no requirement that this method actually matches the executor used.
      Specified by:
      optimizeForDirectExecutor in interface Stream
    • setCompressor

      public void setCompressor(Compressor compressor)
      Description copied from interface: Stream
      Sets the compressor on the framer.
      Specified by:
      setCompressor in interface Stream
      Parameters:
      compressor - the compressor to use
    • setFullStreamDecompression

      public void setFullStreamDecompression(boolean fullStreamDecompression)
      Description copied from interface: ClientStream
      Enables full-stream decompression, allowing the client stream to use GzipInflatingBuffer to decode inbound GZIP compressed streams.
      Specified by:
      setFullStreamDecompression in interface ClientStream
    • setDecompressorRegistry

      public void setDecompressorRegistry(DecompressorRegistry decompressorRegistry)
      Description copied from interface: ClientStream
      Sets the registry to find a decompressor for the framer. May only be called before ClientStream.start(io.grpc.internal.ClientStreamListener). If the transport does not support compression, this may do nothing.
      Specified by:
      setDecompressorRegistry in interface ClientStream
      Parameters:
      decompressorRegistry - the registry of decompressors for decoding responses
    • setMaxInboundMessageSize

      public void setMaxInboundMessageSize(int maxSize)
      Description copied from interface: ClientStream
      Sets the max size accepted from the remote endpoint.
      Specified by:
      setMaxInboundMessageSize in interface ClientStream
    • setMaxOutboundMessageSize

      public void setMaxOutboundMessageSize(int maxSize)
      Description copied from interface: ClientStream
      Sets the max size sent to the remote endpoint.
      Specified by:
      setMaxOutboundMessageSize in interface ClientStream
    • setDeadline

      public void setDeadline(@Nonnull Deadline deadline)
      Description copied from interface: ClientStream
      Sets the effective deadline of the RPC.
      Specified by:
      setDeadline in interface ClientStream
    • appendTimeoutInsight

      public void appendTimeoutInsight(InsightBuilder insight)
      Description copied from interface: ClientStream
      Append information that will be included in the locally generated DEADLINE_EXCEEDED errors to the given InsightBuilder, in order to tell the user about the state of the stream so that they can better diagnose the cause of the error.
      Specified by:
      appendTimeoutInsight in interface ClientStream