Package io.grpc.internal
Interface ServerStream
- All Superinterfaces:
Stream
- All Known Implementing Classes:
AbstractServerStream
Extension of
Stream
to support server-side termination semantics.
An implementation doesn't need to be thread-safe. All methods are expected to execute quickly.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Tears down the stream, typically in the event of a timeout.void
Closes the stream for both reading and writing.Attributes describing stream.Gets the authority this stream is addressed to.void
setDecompressor
(Decompressor decompressor) Sets the decompressor on the deframer.void
setListener
(ServerStreamListener serverStreamListener) Sets the server stream listener.void
setOnReadyThreshold
(int numBytes) A hint to the stream that specifies how many bytes must be queued beforeStream.isReady()
will return false.The context for recording stats and traces for this stream.int
streamId()
The HTTP/2 stream id, or-1
if not supported.void
writeHeaders
(Metadata headers, boolean flush) Writes custom metadata as headers on the response stream sent to the client.Methods inherited from interface io.grpc.internal.Stream
flush, isReady, optimizeForDirectExecutor, request, setCompressor, setMessageCompression, writeMessage
-
Method Details
-
writeHeaders
Writes custom metadata as headers on the response stream sent to the client. This method may only be called once and cannot be called after calls toStream.writeMessage(java.io.InputStream)
orclose(io.grpc.Status, io.grpc.Metadata)
.- Parameters:
headers
- to send to client.
-
close
Closes the stream for both reading and writing. A status code ofStatus.Code.OK
implies normal termination of the stream. Any other value implies abnormal termination.Attempts to read from or write to the stream after closing should be ignored by implementations, and should not throw exceptions.
- Parameters:
status
- details of the closuretrailers
- an additional block of metadata to pass to the client on stream closure.
-
cancel
Tears down the stream, typically in the event of a timeout. This method may be called multiple times and from any thread. -
setDecompressor
Sets the decompressor on the deframer. If the transport does not support compression, this may do nothing.- Parameters:
decompressor
- the decompressor to use.
-
getAttributes
Attributes getAttributes()Attributes describing stream. This is inherited from the transport attributes, and used as the basis ofServerCall.getAttributes()
.- Returns:
- Attributes container
-
getAuthority
Gets the authority this stream is addressed to.- Returns:
- the authority string.
null
if not available.
-
setListener
Sets the server stream listener. -
statsTraceContext
StatsTraceContext statsTraceContext()The context for recording stats and traces for this stream. -
streamId
int streamId()The HTTP/2 stream id, or-1
if not supported. -
setOnReadyThreshold
void setOnReadyThreshold(int numBytes) A hint to the stream that specifies how many bytes must be queued beforeStream.isReady()
will return false. A stream may ignore this property if unsupported. This may only be set during stream initialization before any messages are set.- Parameters:
numBytes
- The number of bytes that must be queued. Must be a positive integer.
-