module
GRPC::Codec
Overview
Codec handles gRPC message framing and optional gzip compression.
Each gRPC message is prefixed with a 5-byte header: Byte 0: Compressed-Flag (0 = not compressed, 1 = gzip compressed) Bytes 1-4: Message-Length (big-endian uint32) — length of the (possibly compressed) body
Defined in:
grpc/codec.crConstant Summary
-
HEADER_SIZE =
5
Class Method Summary
-
.decode(data : Bytes) : Tuple(Bytes, Int32)
Decode reads one gRPC message from the given Bytes slice.
-
.decode_all(data : Bytes) : Array(Bytes)
Decode all gRPC messages from the given Bytes slice.
- .decode_payload(compressed : UInt8, body : Bytes) : Bytes
-
.encode(message_bytes : Bytes, compress : Bool = false) : Bytes
Encode a protobuf-serialized message into a gRPC DATA frame payload.
Class Method Detail
Decode reads one gRPC message from the given Bytes slice. Returns {message_bytes, bytes_consumed}. Decompresses gzip-compressed frames automatically. Raises StatusError on incomplete or malformed frames.
Decode all gRPC messages from the given Bytes slice.
Encode a protobuf-serialized message into a gRPC DATA frame payload.
Pass compress: true to gzip-compress the payload.