grpcext

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: AGPL-3.0 Imports: 26 Imported by: 2

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,
	req InvokeRequest,
	opts ...grpc.CallOption,
) (*InvokeResponse, error)

Invoke executes a unary gRPC request.

func (*Conn) NewStream added in v0.49.0

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 InvokeRequest added in v0.51.0

type InvokeRequest struct {
	Method           string
	MethodDescriptor protoreflect.MethodDescriptor
	Timeout          time.Duration
	TagsAndMeta      *metrics.TagsAndMeta
	Message          []byte
	Metadata         metadata.MD
}

InvokeRequest represents a unary gRPC request.

type InvokeResponse added in v0.51.0

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

InvokeResponse represents a gRPC response.

type Stream added in v0.49.0

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

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

func (*Stream) CloseSend added in v0.49.0

func (s *Stream) CloseSend() error

CloseSend closes the stream

func (*Stream) ReceiveConverted added in v0.49.0

func (s *Stream) ReceiveConverted() (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 added in v0.49.0

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

Send sends the message to the stream

type StreamRequest added in v0.49.0

type StreamRequest struct {
	Method           string
	MethodDescriptor protoreflect.MethodDescriptor
	Timeout          time.Duration
	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