grpcdump

package
v0.0.0-...-b14404a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const OriginClient = "client"
View Source
const OriginServer = "server"

Variables

View Source
var (
	ErrMetadataNotFound      = errors.New("grpcdump: no metadata found")
	ErrUnknownMessageOrigin  = errors.New("grpcdump: unknown message origin")
	ErrInvalidLine           = errors.New("grpcdump: invalid line")
	ErrInvalidDump           = errors.New("grpcdump: invalid dump")
	ErrInvalidMetadata       = errors.New("grpcdump: invalid metadata")
	ErrInvalidMethod         = errors.New("grpcdump: invalid method")
	ErrInvalidOrigin         = errors.New("grpcdump: invalid origin")
	ErrBadClientStreamPrefix = errors.New("grpcdump: bad client stream prefix")
	ErrBadServerStreamPrefix = errors.New("grpcdump: bad server stream prefix")
	ErrMissingGRPCTestID     = errors.New("grpcdump: missing grpcdump test id")
)

Functions

func BadClientStreamPrefixError

func BadClientStreamPrefixError(origin string) error

func BadServerStreamPrefixError

func BadServerStreamPrefixError(origin string) error

func InvalidLineError

func InvalidLineError(line string) error

func InvalidMetadataError

func InvalidMetadataError(text string) error

func InvalidMethodError

func InvalidMethodError(line string) error

func InvalidOriginError

func InvalidOriginError(text string) error

func NewRecorder

func NewRecorder(ctx context.Context) (context.Context, func() *Dump)

NewRecorder generates a new unique id for the request, and propagates it from the client request to the server. The request/response will then be dumped from the server and set to the global map with this id. The client can then retrieve the dump using the same id. The id is automatically cleaned up after the test is done.

func StreamInterceptor

func StreamInterceptor() grpc.ServerOption

func StreamServerInterceptor

func StreamServerInterceptor(srv any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func UnaryClientInterceptor

func UnaryClientInterceptor(ctx context.Context, method string, req, res interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

func UnaryInterceptor

func UnaryInterceptor() grpc.ServerOption

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

func UnknownMessageOriginError

func UnknownMessageOriginError(origin string) error

func WithUnaryInterceptor

func WithUnaryInterceptor() grpc.DialOption

Types

type Dump

type Dump struct {
	Addr           string      `json:"addr"`
	FullMethod     string      `json:"full_method"`
	Messages       []Message   `json:"messages"`
	Status         *Status     `json:"status"`
	Metadata       metadata.MD `json:"metadata"` // The server receives metadata.
	Header         metadata.MD `json:"header"`   // The client receives header and trailer.
	Trailer        metadata.MD `json:"trailer"`
	IsServerStream bool        `json:"isServerStream"`
	IsClientStream bool        `json:"isClientStream"`
	HeaderIdx      int         `json:"-"`
}

https://github.com/bradleyjkemp/grpc-tools/blob/master/grpc-dump/README.md

func (*Dump) AsText

func (d *Dump) AsText() ([]byte, error)

func (*Dump) FromText

func (d *Dump) FromText(b []byte) error

func (*Dump) Method

func (d *Dump) Method() string

func (*Dump) Service

func (d *Dump) Service() string

type Message

type Message struct {
	Origin  string `json:"origin"` // server or client
	Name    string `json:"name"`
	Message any    `json:"message"`
}

type Status

type Status struct {
	Code    string     `json:"code"`
	Number  codes.Code `json:"number"`
	Message string     `json:"message"`
}

func NewStatus

func NewStatus(err error) *Status

Jump to

Keyboard shortcuts

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