Package io.grpc.internal
Interface ServerStream
-
- All Superinterfaces:
Stream
- All Known Implementing Classes:
AbstractServerStream
,InProcessTransport.InProcessStream.InProcessServerStream
,NettyServerStream
,ServletServerStream
,ServletServerStream
public interface ServerStream extends Stream
Extension ofStream
to support server-side termination semantics.An implementation doesn't need to be thread-safe. All methods are expected to execute quickly.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cancel(Status status)
Tears down the stream, typically in the event of a timeout.void
close(Status status, Metadata trailers)
Closes the stream for both reading and writing.Attributes
getAttributes()
Attributes describing stream.java.lang.String
getAuthority()
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.StatsTraceContext
statsTraceContext()
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 Detail
-
writeHeaders
void writeHeaders(Metadata headers, boolean flush)
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
void close(Status status, Metadata trailers)
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
void cancel(Status status)
Tears down the stream, typically in the event of a timeout. This method may be called multiple times and from any thread.
-
setDecompressor
void setDecompressor(Decompressor decompressor)
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
@Nullable java.lang.String getAuthority()
Gets the authority this stream is addressed to.- Returns:
- the authority string.
null
if not available.
-
setListener
void setListener(ServerStreamListener serverStreamListener)
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.
-
-