grpc

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ContentType = "application/grpc+proto"

ContentType is the Content-Type header value for gRPC requests.

Variables

This section is empty.

Functions

func AcceptHeader

func AcceptHeader() core.KeyVal[string]

AcceptHeader returns the Accept header for gRPC requests.

func Frame

func Frame(data []byte, compressed bool) []byte

Frame wraps message in gRPC length-prefixed format. Format: [compressed:1][length:4][data]

func Headers

func Headers() []core.KeyVal[string]

Headers returns the standard headers for gRPC requests.

func Unframe

func Unframe(data []byte) ([]byte, bool, error)

Unframe extracts a gRPC length-prefixed message from the data. Returns the message data and whether it was compressed.

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
	Unavailable        Code = 14
	DataLoss           Code = 15
	Unauthenticated    Code = 16
)

gRPC status codes.

func (Code) String

func (c Code) String() string

String returns the name of the status code.

type Status

type Status struct {
	Code    Code
	Message string
}

Status represents a gRPC status.

func ParseStatus

func ParseStatus(grpcStatus, grpcMessage string) *Status

ParseStatus parses gRPC status from HTTP trailers.

func (*Status) Error

func (s *Status) Error() string

func (*Status) OK

func (s *Status) OK() bool

OK returns true if the status represents success.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL