grpc

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a gRPC client that can be used to make RPC requests

func (*Client) Close

func (c *Client) Close() error

Close will close the client gRPC connection

func (*Client) Connect

func (c *Client) Connect(ctxPtr *context.Context, addr string, params map[string]interface{}) (bool, error)

Connect is a block dial to the gRPC server at the given address (host:port) nolint: funlen

func (*Client) HandleConn

func (*Client) HandleConn(context.Context, grpcstats.ConnStats)

HandleConn implements the stats.Handler interface

func (*Client) HandleRPC

func (c *Client) HandleRPC(ctx context.Context, stat grpcstats.RPCStats)

HandleRPC implements the stats.Handler interface

func (*Client) Invoke

func (c *Client) Invoke(ctxPtr *context.Context,
	method string, req goja.Value, params map[string]interface{}) (*Response, error)

Invoke creates and calls a unary RPC by fully qualified method name nolint: funlen,gocognit,gocyclo

func (*Client) Load

func (c *Client) Load(ctxPtr *context.Context, importPaths []string, filenames ...string) ([]MethodInfo, error)

Load will parse the given proto files and make the file descriptors available to request.

func (*Client) TagConn

TagConn implements the stats.Handler interface

func (*Client) TagRPC

TagRPC implements the stats.Handler interface

type GRPC

type GRPC struct {
	StatusOK                 codes.Code `js:"StatusOK"`
	StatusCanceled           codes.Code `js:"StatusCanceled"`
	StatusUnknown            codes.Code `js:"StatusUnknown"`
	StatusInvalidArgument    codes.Code `js:"StatusInvalidArgument"`
	StatusDeadlineExceeded   codes.Code `js:"StatusDeadlineExceeded"`
	StatusNotFound           codes.Code `js:"StatusNotFound"`
	StatusAlreadyExists      codes.Code `js:"StatusAlreadyExists"`
	StatusPermissionDenied   codes.Code `js:"StatusPermissionDenied"`
	StatusResourceExhausted  codes.Code `js:"StatusResourceExhausted"`
	StatusFailedPrecondition codes.Code `js:"StatusFailedPrecondition"`
	StatusAborted            codes.Code `js:"StatusAborted"`
	StatusOutOfRange         codes.Code `js:"StatusOutOfRange"`
	StatusUnimplemented      codes.Code `js:"StatusUnimplemented"`
	StatusInternal           codes.Code `js:"StatusInternal"`
	StatusUnavailable        codes.Code `js:"StatusUnavailable"`
	StatusDataLoss           codes.Code `js:"StatusDataLoss"`
	StatusUnauthenticated    codes.Code `js:"StatusUnauthenticated"`
}

GRPC represents the gRPC protocol module for k6

func New

func New() *GRPC

New creates a new gRPC module

func (*GRPC) XClient

func (*GRPC) XClient(ctxPtr *context.Context) interface{}

XClient represents the Client constructor (e.g. `new grpc.Client()`) and creates a new gPRC client object that can load protobuf definitions, connect to servers and invoke RPC methods.

type MethodInfo

type MethodInfo struct {
	grpc.MethodInfo `json:"-" js:"-"`
	Package         string
	Service         string
	FullMethod      string
}

MethodInfo holds information on any parsed method descriptors that can be used by the goja VM

type Response

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

Response is a gRPC response that can be used by the goja VM

Jump to

Keyboard shortcuts

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