Documentation
¶
Index ¶
- Constants
- func AcceptHeader() core.KeyVal[string]
- func CheckedFrameLength(messageLength int64) (int64, error)
- func DecodeMessage(data []byte, compressed bool, encoding string) ([]byte, error)
- func DecodeMessageLimited(data []byte, compressed bool, encoding string, max int64) ([]byte, error)
- func Frame(data []byte, compressed bool) []byte
- func FrameChecked(data []byte, compressed bool) ([]byte, error)
- func Headers() []core.KeyVal[string]
- func ReadFrame(r io.Reader) ([]byte, bool, error)
- func ReadFrameBody(r io.Reader, length uint32, max int64) ([]byte, error)
- func ReadFrameHeader(r io.Reader) (uint32, bool, error)
- func Unframe(data []byte) ([]byte, bool, error)
- type Code
- type Status
Constants ¶
const ContentType = "application/grpc+proto"
ContentType is the Content-Type header value for gRPC requests.
const MaxMessageSize int64 = core.MaxGRPCMessageBytes
MaxMessageSize is the maximum encoded or decoded gRPC message size.
Variables ¶
This section is empty.
Functions ¶
func AcceptHeader ¶
AcceptHeader returns the Accept header for gRPC requests.
func CheckedFrameLength ¶ added in v0.28.0
CheckedFrameLength validates the message length and returns the complete wire-frame length. Keeping the addition here prevents every framing caller from having to repeat overflow checks before allocating or writing headers.
func DecodeMessage ¶ added in v0.28.0
DecodeMessage decompresses one gRPC message when its compressed flag is set. Decompression is bounded so a small compressed payload cannot expand beyond the gRPC message limit.
func DecodeMessageLimited ¶ added in v0.28.0
DecodeMessageLimited is DecodeMessage with a caller-supplied decoded-size limit. Reflection uses this to enforce its aggregate limit before retaining another decompressed response.
func Frame ¶
Frame wraps a valid message in gRPC length-prefixed format. Format: [compressed:1][length:4][data]. It returns nil when data cannot be represented by a strict gRPC frame; callers that need the reason should use FrameChecked.
func FrameChecked ¶ added in v0.28.0
FrameChecked wraps a message in gRPC length-prefixed format and rejects messages that cannot be represented by the wire format or exceed the configured message limit.
func ReadFrame ¶ added in v0.17.0
ReadFrame reads a single gRPC length-prefixed frame from the reader. Returns the message data, whether it was compressed, and any error. Returns io.EOF when the reader has no more data.
func ReadFrameBody ¶ added in v0.28.0
ReadFrameBody reads a frame payload after ReadFrameHeader. max is checked before allocation so callers can enforce an operation-wide limit without briefly allocating an over-limit message.
func ReadFrameHeader ¶ added in v0.28.0
ReadFrameHeader reads and validates the five-byte gRPC frame header. It returns io.EOF when the reader has no more data. The payload is not read, which lets callers enforce an aggregate limit before allocating it.
Types ¶
type Code ¶
type Code int
Code represents a gRPC status code.
const ( OK Code = 0 Canceled Code = 1 Unknown Code = 2 InvalidArgument Code = 3 DeadlineExceeded Code = 4 NotFound Code = 5 AlreadyExists Code = 6 PermissionDenied Code = 7 ResourceExhausted Code = 8 FailedPrecondition Code = 9 Aborted Code = 10 OutOfRange Code = 11 Unimplemented Code = 12 Internal Code = 13 DataLoss Code = 15 Unauthenticated Code = 16 )
gRPC status codes.
type Status ¶
Status represents a gRPC status.
func ParseStatus ¶
ParseStatus parses gRPC status from HTTP trailers.