grpc

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 50 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Spec added in v1.30.0

func Spec() actionspec.Spec

Spec declares the grpc action. It keeps to every kind of guard: it calls only a method declared without side effects under read-only, and connects only to a host the guard allows. proto, the .proto files of the service, which it reads apart from Req, asks it to check a step against them. Its res holds, besides the fields of Res, violations and contract, for a call checked against .proto files, and messages and complete, for one whose responses stream. It cannot run without addr, service and method.

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