public abstract class AbstractClientStream extends AbstractStream implements ClientStream, MessageFramer.Sink
ClientStream
implementations. Extending classes only need to
implement transportState()
and abstractClientStreamSink()
. Must only be called
from the sending application thread.Modifier and Type | Class and Description |
---|---|
protected static interface |
AbstractClientStream.Sink
A sink for outbound operations, separated from the stream simply to avoid name
collisions/confusion.
|
protected static class |
AbstractClientStream.TransportState
This should only called from the transport thread.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractClientStream(WritableBufferAllocator bufferAllocator,
StatsTraceContext statsTraceCtx,
TransportTracer transportTracer,
Metadata headers,
CallOptions callOptions,
boolean useGet) |
Modifier and Type | Method and Description |
---|---|
protected abstract AbstractClientStream.Sink |
abstractClientStreamSink()
Sink for transport to be called to perform outbound operations.
|
void |
cancel(Status reason)
Abnormally terminates the stream.
|
void |
deliverFrame(WritableBuffer frame,
boolean endOfStream,
boolean flush,
int numMessages)
Delivers a frame via the transport.
|
protected Framer |
framer()
The framer to use for sending messages.
|
protected TransportTracer |
getTransportTracer() |
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 |
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.
|
boolean |
shouldBeCountedForInUse()
Returns true if this stream should be counted when determining the in-use state of the
transport.
|
void |
start(ClientStreamListener listener)
Starts stream.
|
protected abstract AbstractClientStream.TransportState |
transportState()
Obtain the transport state corresponding to this stream.
|
endOfMessages, flush, onSendingBytes, setCompressor, setMessageCompression, writeMessage
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAttributes, setAuthority
flush, setCompressor, setMessageCompression, writeMessage
protected AbstractClientStream(WritableBufferAllocator bufferAllocator, StatsTraceContext statsTraceCtx, TransportTracer transportTracer, Metadata headers, CallOptions callOptions, boolean useGet)
public void setDeadline(Deadline deadline)
ClientStream
setDeadline
in interface ClientStream
public void setMaxOutboundMessageSize(int maxSize)
ClientStream
setMaxOutboundMessageSize
in interface ClientStream
public void setMaxInboundMessageSize(int maxSize)
ClientStream
setMaxInboundMessageSize
in interface ClientStream
public final void setFullStreamDecompression(boolean fullStreamDecompression)
ClientStream
GzipInflatingBuffer
to decode inbound GZIP compressed streams.setFullStreamDecompression
in interface ClientStream
public final 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 responsesprotected abstract AbstractClientStream.TransportState transportState()
transportState
in class AbstractStream
public final 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 eventsprotected abstract AbstractClientStream.Sink abstractClientStreamSink()
protected final Framer framer()
AbstractStream
framer
in class AbstractStream
public final boolean shouldBeCountedForInUse()
public final 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 final void deliverFrame(WritableBuffer frame, boolean endOfStream, boolean flush, int numMessages)
MessageFramer.Sink
deliverFrame
in interface MessageFramer.Sink
frame
- a non-empty buffer to deliver or null
if the framer is being
closed and there is no data to deliver.endOfStream
- whether the frame is the last one for the GRPC streamflush
- true
if more data may not be arriving soonnumMessages
- the number of messages that this series of frames representspublic final void halfClose()
ClientStream
ClientStream.start(io.grpc.internal.ClientStreamListener)
.halfClose
in interface ClientStream
public final void cancel(Status reason)
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
reason
- must be non-OKpublic final 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.
isReady
in interface Stream
isReady
in class AbstractStream
protected TransportTracer getTransportTracer()