grpc

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keeps added in v1.21.0

func Keeps() []string

Keeps returns the kinds of guard the grpc action keeps to: it calls only a method declared without side effects under read-only, and connects only to a host the guard allows.

func NewCoverage added in v1.20.0

func NewCoverage(path string, r *report.Report) (*oas.Coverage, error)

NewCoverage counts the steps of r that called each method the .proto file at path declares, as proto.files names the file. The file is parsed on its own, without its imports, as its services and methods are all that is counted. A .proto file declares no statuses its methods end with, so that its coverage is told by methods alone.

func Params added in v1.20.0

func Params() []string

Params returns the keys the grpc action takes in with: those of Req, and proto, which it reads apart from Req.

func Request added in v1.18.0

func Request(data map[string]any, opts ...Option) (map[string]any, error)

func RequestStep added in v1.21.0

func RequestStep(call actionrpc.Call, opts ...Option) (map[string]any, error)

RequestStep is Request for a step, made under the guard of the run.

func Serve

func Serve()

Types

type Action

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

func (*Action) Run

func (a *Action) Run(with map[string]any) (map[string]any, error)

func (*Action) RunStep added in v1.21.0

func (a *Action) RunStep(call actionrpc.Call) (map[string]any, map[string]any, error)

RunStep makes the call for a step, under the guard of the run, which refuses a host it does not allow and, under --read-only, a method its definitions do not declare free of side effects.

type Callback added in v1.18.0

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

type Option added in v1.18.0

type Option func(*Callback)

func WithAfter added in v1.18.0

func WithAfter(f func(res *Res)) Option

func WithBefore added in v1.18.0

func WithBefore(f func(ctx context.Context, service, method string)) Option

type Req added in v1.18.0

type Req struct {
	// Protocol is how the call is made: grpc, the default, or connect, the
	// Connect protocol over HTTP, which reaches a server through an HTTP/1.1
	// proxy too.
	Protocol string            `map:"protocol"`
	Addr     string            `map:"addr" validate:"required"`
	Service  string            `map:"service" validate:"required"`
	Method   string            `map:"method" validate:"required"`
	Body     string            `map:"body"`
	Timeout  string            `map:"timeout"`
	TLS      bool              `map:"tls"`
	Insecure bool              `map:"insecure"`
	CertFile string            `map:"cert_file"`
	KeyFile  string            `map:"key_file"`
	CAFile   string            `map:"ca_file"`
	Metadata map[string]string `map:"metadata"`
	// Codec is how a Connect call encodes its messages: json, the default,
	// or proto. A gRPC call takes none.
	Codec string `map:"codec"`
	// MaxMessages, when it is above 0, is how many responses of a stream
	// are read before the call is left.
	MaxMessages int `map:"max_messages"`
	// contains filtered or unexported fields
}

func NewReq added in v1.18.0

func NewReq() *Req

func (*Req) Do added in v1.18.0

func (r *Req) Do() (re *Result, er error)

type Res added in v1.18.0

type Res struct {
	Body          string            `map:"body"`
	StatusCode    string            `map:"status_code"`
	StatusMessage string            `map:"status_message"`
	Metadata      map[string]string `map:"metadata"`
	// contains filtered or unexported fields
}

type Result added in v1.18.0

type Result struct {
	Req    Req           `map:"req"`
	Res    Res           `map:"res"`
	RT     time.Duration `map:"rt"`
	Status int           `map:"status"`
}

Directories

Path Synopsis
pb

Jump to

Keyboard shortcuts

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