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,
io.grpc.Metadata headers,
io.grpc.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(io.grpc.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(io.grpc.Deadline deadline)
Sets the effective deadline of the RPC.
|
void |
setDecompressorRegistry(io.grpc.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, writeMessageclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAttributes, setAuthorityflush, setCompressor, setMessageCompression, writeMessageprotected AbstractClientStream(WritableBufferAllocator bufferAllocator, StatsTraceContext statsTraceCtx, TransportTracer transportTracer, io.grpc.Metadata headers, io.grpc.CallOptions callOptions, boolean useGet)
public void setDeadline(io.grpc.Deadline deadline)
ClientStreamsetDeadline in interface ClientStreampublic void setMaxOutboundMessageSize(int maxSize)
ClientStreamsetMaxOutboundMessageSize in interface ClientStreampublic void setMaxInboundMessageSize(int maxSize)
ClientStreamsetMaxInboundMessageSize in interface ClientStreampublic final void setFullStreamDecompression(boolean fullStreamDecompression)
ClientStreamGzipInflatingBuffer to decode inbound GZIP compressed streams.setFullStreamDecompression in interface ClientStreampublic final void setDecompressorRegistry(io.grpc.DecompressorRegistry decompressorRegistry)
ClientStreamClientStream.start(io.grpc.internal.ClientStreamListener). If the transport does not support compression, this may do nothing.setDecompressorRegistry in interface ClientStreamdecompressorRegistry - the registry of decompressors for decoding responsesprotected abstract AbstractClientStream.TransportState transportState()
transportState in class AbstractStreampublic final void start(ClientStreamListener listener)
ClientStreamClientStream.start(io.grpc.internal.ClientStreamListener) is called.
This method should not throw any exceptions.
start in interface ClientStreamlistener - non-null listener of stream eventsprotected abstract AbstractClientStream.Sink abstractClientStreamSink()
protected final Framer framer()
AbstractStreamframer in class AbstractStreampublic final boolean shouldBeCountedForInUse()
public final void request(int numMessages)
StreamStreamListener.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.SinkdeliverFrame in interface MessageFramer.Sinkframe - 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()
ClientStreamClientStream.start(io.grpc.internal.ClientStreamListener).halfClose in interface ClientStreampublic final void cancel(io.grpc.Status reason)
ClientStreamClientStreamListener.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 ClientStreamreason - must be non-OKpublic final boolean isReady()
Streamtrue, 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 StreamisReady in class AbstractStreamprotected TransportTracer getTransportTracer()