public class NoopClientStream extends Object implements ClientStream
ClientStream
that silently does nothing for the operations.Modifier and Type | Field and Description |
---|---|
static NoopClientStream |
INSTANCE |
Constructor and Description |
---|
NoopClientStream() |
Modifier and Type | Method and Description |
---|---|
void |
appendTimeoutInsight(InsightBuilder insight)
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. |
void |
cancel(Status status)
Abnormally terminates the stream.
|
void |
flush()
Flushes any internally buffered messages to the remote end-point.
|
Attributes |
getAttributes()
Attributes that the stream holds at the current moment.
|
void |
halfClose()
Closes the local side of this stream and flushes any remaining messages.
|
boolean |
isReady()
If
true , indicates that the transport is capable of sending additional messages without
requiring excessive buffering internally. |
void |
request(int numMessages)
Requests up to the given number of messages from the call to be delivered via
StreamListener.messagesAvailable(StreamListener.MessageProducer) . |
void |
setAuthority(String authority)
Override the default authority with
authority . |
void |
setCompressor(Compressor compressor)
Sets the compressor on the framer.
|
void |
setDeadline(Deadline deadline)
Sets the effective deadline of the RPC.
|
void |
setDecompressorRegistry(DecompressorRegistry decompressorRegistry)
Sets the registry to find a decompressor for the framer.
|
void |
setFullStreamDecompression(boolean fullStreamDecompression)
Enables full-stream decompression, allowing the client stream to use
GzipInflatingBuffer to decode inbound GZIP compressed streams. |
void |
setMaxInboundMessageSize(int maxSize)
Sets the max size accepted from the remote endpoint.
|
void |
setMaxOutboundMessageSize(int maxSize)
Sets the max size sent to the remote endpoint.
|
void |
setMessageCompression(boolean enable)
Enables per-message compression, if an encoding type has been negotiated.
|
void |
start(ClientStreamListener listener)
Starts stream.
|
void |
writeMessage(InputStream message)
Writes a message payload to the remote end-point.
|
public static final NoopClientStream INSTANCE
public void setAuthority(String authority)
ClientStream
authority
. May only be called before ClientStream.start(io.grpc.internal.ClientStreamListener)
.setAuthority
in interface ClientStream
public void start(ClientStreamListener listener)
ClientStream
ClientStream.start(io.grpc.internal.ClientStreamListener)
is called.
This method should not throw any exceptions.
start
in interface ClientStream
listener
- non-null
listener of stream eventspublic Attributes getAttributes()
ClientStream
getAttributes
in interface ClientStream
public void request(int numMessages)
Stream
StreamListener.messagesAvailable(StreamListener.MessageProducer)
. No additional
messages will be delivered. If the stream has a start()
method, it must be called
before requesting messages.public void writeMessage(InputStream message)
Stream
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()
.
writeMessage
in interface Stream
message
- stream containing the serialized message to be sentpublic void flush()
Stream
public boolean isReady()
Stream
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.
public void cancel(Status status)
ClientStream
ClientStreamListener.closed(io.grpc.Status, 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.cancel
in interface ClientStream
status
- must be non-OKpublic void halfClose()
ClientStream
ClientStream.start(io.grpc.internal.ClientStreamListener)
.halfClose
in interface ClientStream
public void setMessageCompression(boolean enable)
Stream
setMessageCompression
in interface Stream
public void setCompressor(Compressor compressor)
Stream
setCompressor
in interface Stream
compressor
- the compressor to usepublic void setFullStreamDecompression(boolean fullStreamDecompression)
ClientStream
GzipInflatingBuffer
to decode inbound GZIP compressed streams.setFullStreamDecompression
in interface ClientStream
public void setDecompressorRegistry(DecompressorRegistry decompressorRegistry)
ClientStream
ClientStream.start(io.grpc.internal.ClientStreamListener)
. If the transport does not support compression, this may do nothing.setDecompressorRegistry
in interface ClientStream
decompressorRegistry
- the registry of decompressors for decoding responsespublic void setMaxInboundMessageSize(int maxSize)
ClientStream
setMaxInboundMessageSize
in interface ClientStream
public void setMaxOutboundMessageSize(int maxSize)
ClientStream
setMaxOutboundMessageSize
in interface ClientStream
public void setDeadline(@Nonnull Deadline deadline)
ClientStream
setDeadline
in interface ClientStream
public void appendTimeoutInsight(InsightBuilder insight)
ClientStream
InsightBuilder
, in order to tell the user about the state of the stream so
that they can better diagnose the cause of the error.appendTimeoutInsight
in interface ClientStream
Copyright © 2019. All rights reserved.