Help us shape the future of Go! Take the 2026 Go Developer Survey

grpcclient

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 41 Imported by: 13

Documentation

Index

Constants

View Source
const (
	ErrDifferentSignaturePresent = errors.Error("different signature already present")
	ErrMultipleSignaturePresent  = errors.Error("multiples signature present")
	ErrSignatureNotPresent       = errors.Error("signature not present")
	ErrSignatureMismatch         = errors.Error("signature mismatch")
)

Variables

This section is empty.

Functions

func Instrument added in v1.1.0

func InstrumentReusableStream added in v1.20.0

func InstrumentReusableStream(requestDuration *prometheus.HistogramVec) ([]grpc.UnaryClientInterceptor, []grpc.StreamClientInterceptor)

func NewBackoffRetry

func NewBackoffRetry(cfg backoff.Config) grpc.UnaryClientInterceptor

NewBackoffRetry gRPC middleware.

func NewRateLimiter

func NewRateLimiter(cfg *Config) grpc.UnaryClientInterceptor

NewRateLimiter creates a UnaryClientInterceptor for client side rate limiting.

func NewStreamSigningClientInterceptor added in v1.21.1

func NewStreamSigningClientInterceptor(key string) grpc.StreamClientInterceptor

NewStreamSigningClientInterceptor returns a gRPC stream client interceptor that injects an HMAC-SHA256 signature into the outgoing stream metadata.

func NewStreamSigningServerInterceptor added in v1.21.1

func NewStreamSigningServerInterceptor(keys ...string) grpc.StreamServerInterceptor

NewStreamSigningServerInterceptor returns a gRPC stream server interceptor that verifies the HMAC-SHA256 signature injected by NewStreamSigningClientInterceptor.

func UnarySigningClientInterceptor added in v1.16.0

func UnarySigningClientInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

func UnarySigningServerInterceptor added in v1.16.0

func UnarySigningServerInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error)

Types

type Config

type Config struct {
	MaxRecvMsgSize  int     `yaml:"max_recv_msg_size"`
	MaxSendMsgSize  int     `yaml:"max_send_msg_size"`
	GRPCCompression string  `yaml:"grpc_compression"`
	RateLimit       float64 `yaml:"rate_limit"`
	RateLimitBurst  int     `yaml:"rate_limit_burst"`

	BackoffOnRatelimits bool           `yaml:"backoff_on_ratelimits"`
	BackoffConfig       backoff.Config `yaml:"backoff_config"`

	TLSEnabled               bool             `yaml:"tls_enabled"`
	TLS                      tls.ClientConfig `yaml:",inline"`
	SignWriteRequestsEnabled bool             `yaml:"-"`
	SignWriteRequestsKey     string           `yaml:"-"`

	ConnectTimeout time.Duration `yaml:"connect_timeout"`
}

Config for a gRPC client.

func (*Config) CallOptions

func (cfg *Config) CallOptions() []grpc.CallOption

CallOptions returns the config in terms of CallOptions.

func (*Config) DialOption

func (cfg *Config) DialOption(unaryClientInterceptors []grpc.UnaryClientInterceptor, streamClientInterceptors []grpc.StreamClientInterceptor) ([]grpc.DialOption, error)

DialOption returns the config as a grpc.DialOptions.

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

RegisterFlags registers flags.

func (*Config) RegisterFlagsWithPrefix added in v1.1.0

func (cfg *Config) RegisterFlagsWithPrefix(prefix, defaultGrpcCompression string, f *flag.FlagSet)

RegisterFlagsWithPrefix registers flags with prefix.

func (*Config) Validate added in v1.3.0

func (cfg *Config) Validate(log log.Logger) error

type ConfigWithHealthCheck added in v1.19.0

type ConfigWithHealthCheck struct {
	Config            `yaml:",inline"`
	HealthCheckConfig HealthCheckConfig `` /* 179-byte string literal not displayed */
}

func (*ConfigWithHealthCheck) DialOption added in v1.19.0

func (cfg *ConfigWithHealthCheck) DialOption(unaryClientInterceptors []grpc.UnaryClientInterceptor, streamClientInterceptors []grpc.StreamClientInterceptor) ([]grpc.DialOption, error)

func (*ConfigWithHealthCheck) RegisterFlagsWithPrefix added in v1.19.0

func (cfg *ConfigWithHealthCheck) RegisterFlagsWithPrefix(prefix, defaultGrpcCompression string, f *flag.FlagSet)

type HealthCheckConfig added in v1.19.0

type HealthCheckConfig struct {
	*HealthCheckInterceptors `yaml:"-"`

	UnhealthyThreshold int64         `yaml:"unhealthy_threshold"`
	Interval           time.Duration `yaml:"interval"`
	Timeout            time.Duration `yaml:"timeout"`
}

func (*HealthCheckConfig) RegisterFlagsWithPrefix added in v1.19.0

func (cfg *HealthCheckConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)

RegisterFlagsWithPrefix for Config.

type HealthCheckInterceptors added in v1.19.0

type HealthCheckInterceptors struct {
	services.Service

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewHealthCheckInterceptors added in v1.19.0

func NewHealthCheckInterceptors(logger log.Logger) *HealthCheckInterceptors

func (*HealthCheckInterceptors) StreamClientInterceptor added in v1.19.0

func (h *HealthCheckInterceptors) StreamClientInterceptor(clientConfig *ConfigWithHealthCheck) grpc.StreamClientInterceptor

func (*HealthCheckInterceptors) UnaryHealthCheckInterceptor added in v1.19.0

func (h *HealthCheckInterceptors) UnaryHealthCheckInterceptor(clientConfig *ConfigWithHealthCheck) grpc.UnaryClientInterceptor

type SignRequest added in v1.16.0

type SignRequest interface {
	// Sign returns the signature for the given request
	Sign(context.Context) (string, error)
	// VerifySign returns true if the signature is valid
	VerifySign(context.Context, string) (bool, error)
}

SignRequest define the interface that must be implemented by the request structs to be signed

Jump to

Keyboard shortcuts

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