livery_grpc_wire (livery_grpc v0.1.0)
View SourceMessage <-> wire glue shared by the server and the client.
Combines the three wire concerns into one place: protobuf coding
(livery_grpc_codec), per-message compression (livery_grpc_compression),
and length-prefixed framing (livery_grpc_frame). The server and client
encode and decode messages through here so the rules stay identical on
both sides.
Summary
Functions
Decode every whole frame in Bin as MsgName. Returns {error, incomplete} if a trailing partial frame remains, or the first frame's
decode error. Max caps a single message's declared length.
Decode one framed message: decompress per the frame flag and message
Encoding, then protobuf-decode as MsgName.
Encode one message to a wire frame: protobuf-encode, compress with
Algorithm, then length-prefix.
Functions
-spec decode_all(module(), atom(), livery_grpc_compression:algorithm(), binary(), non_neg_integer() | infinity) -> {ok, [map() | tuple()]} | {error, term()}.
Decode every whole frame in Bin as MsgName. Returns {error, incomplete} if a trailing partial frame remains, or the first frame's
decode error. Max caps a single message's declared length.
-spec decode_frame(module(), atom(), livery_grpc_compression:algorithm(), livery_grpc_frame:frame()) -> {ok, map() | tuple()} | {error, term()}.
Decode one framed message: decompress per the frame flag and message
Encoding, then protobuf-decode as MsgName.
-spec encode(module(), atom(), map() | tuple(), livery_grpc_compression:algorithm()) -> {ok, iodata()} | {error, {encode, term()}}.
Encode one message to a wire frame: protobuf-encode, compress with
Algorithm, then length-prefix.