grpc

package
v1.26.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keeps

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

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

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

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

func RequestStep

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

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

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

type Option

type Option func(*Callback)

func WithAfter

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

func WithBefore

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

type Req

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

func NewReq() *Req

func (*Req) Do

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

type Res

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

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