Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // EndStreamHeader is a gRPC frame header that indicates EOS. // This is ok because the MSB of the data frame header will never be used by // the gRPC protocol. gRPC-Web utilizes it to distinguish between normal data and trailers, // which implies we may also use it for our own purposes. // We use it to indicate that the stream is complete. EndStreamHeader = []byte{metadataMask, 0, 0, 0, 0} )
Functions ¶
func IsCompressed ¶
IsCompressed returns true if the message header sets the compression flag.
func IsDataFrame ¶
IsDataFrame returns true if the message is a gRPC data frame. A data frame has its MSB unset.
func IsEndOfStream ¶
IsEndOfStream returns true if the header sets the EOS flag and the message is empty.
func IsMetadataFrame ¶
IsMetadataFrame returns true if the message is a gRPC metadata frame. A metadata frame has its MSB set.
func MakeMessageHeader ¶
func MakeMessageHeader(flags MessageFlags, length uint32) []byte
MakeMessageHeader creates a gRPC message frame header based on the given flags and message length.
func ValidateGRPCFrame ¶
ValidateGRPCFrame ensures the message is a well-formed gRPC message. A well-formed message has at least a well-formed header and a length equal to the declared length.
Types ¶
type MessageFlags ¶
type MessageFlags uint8
MessageFlags type represents the flags set in the header of a gRPC data frame.
const ( // MessageHeaderLength is the length of a gRPC data frame message header. MessageHeaderLength = 5 // MetadataFlags is flags with the MSB set to 1 to indicate a metadata gRPC message. MetadataFlags MessageFlags = metadataMask )
func ParseMessageHeader ¶
func ParseMessageHeader(header []byte) (MessageFlags, uint32, error)
ParseMessageHeader parses a byte slice into a gRPC data frame header.