Class InProcessTransport.InProcessStream.InProcessClientStream
java.lang.Object
io.grpc.inprocess.InProcessTransport.InProcessStream.InProcessClientStream
- All Implemented Interfaces:
ClientStream, Stream
- Enclosing class:
InProcessTransport.InProcessStream
private class InProcessTransport.InProcessStream.InProcessClientStream
extends Object
implements ClientStream
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final CallOptionsprivate booleanprivate intprivate booleanprivate ArrayDeque<StreamListener.MessageProducer> private intprivate ServerStreamListener(package private) final StatsTraceContextprivate final SynchronizationContext -
Constructor Summary
ConstructorsConstructorDescriptionInProcessClientStream(CallOptions callOptions, StatsTraceContext statsTraceContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendTimeoutInsight(InsightBuilder insight) Append information that will be included in the locally generated DEADLINE_EXCEEDED errors to the givenInsightBuilder, in order to tell the user about the state of the stream so that they can better diagnose the cause of the error.voidAbnormally terminates the stream.voidflush()Flushes any internally buffered messages to the remote end-point.Attributes that the stream holds at the current moment.voidCloses the local side of this stream and flushes any remaining messages.private booleaninternalCancel(Status serverListenerStatus, Status serverTracerStatus) booleanisReady()Iftrue, indicates that the transport is capable of sending additional messages without requiring excessive buffering internally.voidProvides a hint that directExecutor is being used by the listener for callbacks to the application.voidrequest(int numMessages) Requests up to the given number of messages from the call to be delivered viaStreamListener.messagesAvailable(StreamListener.MessageProducer).private voidserverClosed(Status serverListenerStatus, Status serverTracerStatus) private booleanserverRequested(int numMessages) Client requested more messages.voidsetAuthority(String string) Override the default authority withauthority.voidsetCompressor(Compressor compressor) Sets the compressor on the framer.voidsetDeadline(Deadline deadline) Sets the effective deadline of the RPC.voidsetDecompressorRegistry(DecompressorRegistry decompressorRegistry) Sets the registry to find a decompressor for the framer.voidsetFullStreamDecompression(boolean fullStreamDecompression) Enables full-stream decompression, allowing the client stream to useGzipInflatingBufferto decode inbound GZIP compressed streams.private voidsetListener(ServerStreamListener listener) voidsetMaxInboundMessageSize(int maxSize) Sets the max size accepted from the remote endpoint.voidsetMaxOutboundMessageSize(int maxSize) Sets the max size sent to the remote endpoint.voidsetMessageCompression(boolean enable) Enables per-message compression, if an encoding type has been negotiated.voidstart(ClientStreamListener listener) Starts stream.voidwriteMessage(InputStream message) Writes a message payload to the remote end-point.
-
Field Details
-
statsTraceCtx
-
callOptions
-
serverStreamListener
-
syncContext
-
serverRequested
private int serverRequested -
serverReceiveQueue
-
serverNotifyHalfClose
private boolean serverNotifyHalfClose -
closed
private boolean closed -
outboundSeqNo
private int outboundSeqNo
-
-
Constructor Details
-
InProcessClientStream
InProcessClientStream(CallOptions callOptions, StatsTraceContext statsTraceContext)
-
-
Method Details
-
setListener
-
request
public void request(int numMessages) Description copied from interface:StreamRequests up to the given number of messages from the call to be delivered viaStreamListener.messagesAvailable(StreamListener.MessageProducer). No additional messages will be delivered. If the stream has astart()method, it must be called before requesting messages. -
serverRequested
private boolean serverRequested(int numMessages) Client requested more messages.- Returns:
- whether onReady should be called on the server
-
serverClosed
-
writeMessage
Description copied from interface:StreamWrites 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 areKnownLengthto improve efficiency. This method will always return immediately and will not wait for the write to complete. If the stream has astart()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:
writeMessagein interfaceStream- Parameters:
message- stream containing the serialized message to be sent
-
flush
-
isReady
public boolean isReady()Description copied from interface:StreamIftrue, indicates that the transport is capable of sending additional messages without requiring excessive buffering internally. Otherwise,StreamListener.onReady()will be called when it turnstrue.This is just a suggestion and the application is free to ignore it, however doing so may result in excessive buffering within the transport.
-
cancel
Description copied from interface:ClientStreamAbnormally 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 untilClientStreamListener.closed(Status, ClientStreamListener.RpcProgress, Metadata)is called. This method may only be called afterClientStream.start(ClientStreamListener), but else is safe to be called at any time and multiple times and from any thread.- Specified by:
cancelin interfaceClientStream- Parameters:
reason- must be non-OK
-
internalCancel
-
halfClose
public void halfClose()Description copied from interface:ClientStreamCloses 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 afterClientStream.start(ClientStreamListener).- Specified by:
halfClosein interfaceClientStream
-
setMessageCompression
public void setMessageCompression(boolean enable) Description copied from interface:StreamEnables 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:
setMessageCompressionin interfaceStream
-
setAuthority
Description copied from interface:ClientStreamOverride the default authority withauthority. May only be called beforeClientStream.start(ClientStreamListener).- Specified by:
setAuthorityin interfaceClientStream
-
start
Description copied from interface:ClientStreamStarts stream. This method may only be called once. It is safe to do latent initialization of the stream up untilClientStream.start(ClientStreamListener)is called.This method should not throw any exceptions.
- Specified by:
startin interfaceClientStream- Parameters:
listener- non-nulllistener of stream events
-
getAttributes
Description copied from interface:ClientStreamAttributes 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:
getAttributesin interfaceClientStream
-
optimizeForDirectExecutor
public void optimizeForDirectExecutor()Description copied from interface:StreamProvides 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:
optimizeForDirectExecutorin interfaceStream
-
setCompressor
Description copied from interface:StreamSets the compressor on the framer.- Specified by:
setCompressorin interfaceStream- Parameters:
compressor- the compressor to use
-
setFullStreamDecompression
public void setFullStreamDecompression(boolean fullStreamDecompression) Description copied from interface:ClientStreamEnables full-stream decompression, allowing the client stream to useGzipInflatingBufferto decode inbound GZIP compressed streams.- Specified by:
setFullStreamDecompressionin interfaceClientStream
-
setDecompressorRegistry
Description copied from interface:ClientStreamSets the registry to find a decompressor for the framer. May only be called beforeClientStream.start(ClientStreamListener). If the transport does not support compression, this may do nothing.- Specified by:
setDecompressorRegistryin interfaceClientStream- Parameters:
decompressorRegistry- the registry of decompressors for decoding responses
-
setMaxInboundMessageSize
public void setMaxInboundMessageSize(int maxSize) Description copied from interface:ClientStreamSets the max size accepted from the remote endpoint.- Specified by:
setMaxInboundMessageSizein interfaceClientStream
-
setMaxOutboundMessageSize
public void setMaxOutboundMessageSize(int maxSize) Description copied from interface:ClientStreamSets the max size sent to the remote endpoint.- Specified by:
setMaxOutboundMessageSizein interfaceClientStream
-
setDeadline
Description copied from interface:ClientStreamSets the effective deadline of the RPC.- Specified by:
setDeadlinein interfaceClientStream
-
appendTimeoutInsight
Description copied from interface:ClientStreamAppend information that will be included in the locally generated DEADLINE_EXCEEDED errors to the givenInsightBuilder, 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:
appendTimeoutInsightin interfaceClientStream
-