livery_grpc_stream (livery_grpc v0.1.1)
View SourceA server-side stream handle for client-streaming and bidirectional RPCs.
The handle wraps the request body as a sequence of decoded messages
(recv/1, recv_all/1) and, for bidirectional calls, a send/2 that
frames and emits a reply. Both run in the request worker: request DATA
arrives through livery's body reader and replies go out through the
chunked-response emitter, so a handler can read and write on the one
stream by interleaving recv/1 and send/2.
recv/1 threads the handle (it advances a frame buffer), the way
livery_body:read/2 threads its reader.
Summary
Functions
A bidirectional handle: receive requests and send replies.
A receive-only handle (client-streaming).
Receive the next request message. {ok, Msg, Stream} for a message,
{eof, Stream} once the client has half-closed and the buffer is drained,
or {error, Reason, Stream}.
Receive every remaining request message into a list.
Frame and send one reply message (bidirectional calls only).
Types
Functions
-spec bidi(livery_req:req(), livery_grpc_service:method(), fun((iodata()) -> ok | {error, term()}), livery_grpc_compression:algorithm()) -> stream().
A bidirectional handle: receive requests and send replies.
-spec reader(livery_req:req(), livery_grpc_service:method()) -> stream().
A receive-only handle (client-streaming).
-spec recv(stream()) -> {ok, map() | tuple(), stream()} | {eof, stream()} | {error, term(), stream()}.
Receive the next request message. {ok, Msg, Stream} for a message,
{eof, Stream} once the client has half-closed and the buffer is drained,
or {error, Reason, Stream}.
Receive every remaining request message into a list.
Frame and send one reply message (bidirectional calls only).