grpcext

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package grpcext allows gRPC requests collecting stats info.

Index

Constants

This section is empty.

Variables

View Source
var ErrCanceled = errors.New("canceled by client (k6)")

ErrCanceled canceled by client (k6)

Functions

func DebugStat

func DebugStat(logger logrus.FieldLogger, stat grpcstats.RPCStats, httpDebugOption string)

DebugStat prints debugging information based on RPCStats.

func DefaultOptions

func DefaultOptions(getState func() *lib.State) []grpc.DialOption

DefaultOptions generates an option set with common options for requests from a VU.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is a gRPC client connection.

func Dial

func Dial(ctx context.Context, addr string, options ...grpc.DialOption) (*Conn, error)

Dial establish a gRPC connection.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the underhood connection.

func (*Conn) Invoke

func (c *Conn) Invoke(
	ctx context.Context,
	url string,
	md metadata.MD,
	req Request,
	opts ...grpc.CallOption,
) (*Response, error)

Invoke executes a unary gRPC request.

func (*Conn) NewStream

func (c *Conn) NewStream(
	ctx context.Context,
	req StreamRequest,
	opts ...grpc.CallOption,
) (*Stream, error)

NewStream creates a new gRPC stream.

func (*Conn) Reflect

Reflect returns using the reflection the FileDescriptorSet describing the service.

type Request

type Request struct {
	MethodDescriptor protoreflect.MethodDescriptor
	TagsAndMeta      *metrics.TagsAndMeta
	Message          []byte
}

Request represents a gRPC request.

type Response

type Response struct {
	Message  interface{}
	Error    interface{}
	Headers  map[string][]string
	Trailers map[string][]string
	Status   codes.Code
}

Response represents a gRPC response.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream is the wrapper around the grpc.ClientStream with some handy methods.

func (*Stream) CloseSend

func (s *Stream) CloseSend() error

CloseSend closes the stream

func (*Stream) ReceiveConverted

func (s *Stream) ReceiveConverted() (map[string]interface{}, error)

ReceiveConverted receives a converted message from the stream if the stream has been closed successfully, it returns io.EOF if the stream has been cancelled, it returns ErrCanceled

func (*Stream) Send

func (s *Stream) Send(b []byte) error

Send sends the message to the stream

type StreamRequest

type StreamRequest struct {
	Method           string
	MethodDescriptor protoreflect.MethodDescriptor
	TagsAndMeta      *metrics.TagsAndMeta
	Metadata         metadata.MD
}

StreamRequest represents a gRPC stream request.

Jump to

Keyboard shortcuts

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