infragrpcclient

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFailedToConnect = errors.New("failed to bring connection to ready state")

Functions

func StringToCodeHookFunc

func StringToCodeHookFunc() mapstructure.DecodeHookFuncType

Types

type ConnectionConfig

type ConnectionConfig struct {
	// GRPC Service address.
	// See https://github.com/grpc/grpc/blob/master/doc/naming.md for format. TLDR: "host:port" is okay
	Address string `mapstructure:"address"`

	// Keepalive options
	Keepalive *KeepaliveConfig

	// Retry policy config
	Retry *RetryConfig `mapstructure:"retry"`

	// Max outgoing grpc request size in megabytes
	MaxGrpcSendMsgSizeMB int `mapstructure:"max_grpc_send_msg_size_mb"`

	// Max incoming grpc request size in megabytes
	MaxGrpcRecvMsgSizeMB int `mapstructure:"max_grpc_recv_msg_size_mb"`

	// TLSConfig: unused
	TLS *TLSConfig `mapstructure:"tls"`

	// Lazy defines if the connection should be established immediately
	Lazy bool `mapstructure:"lazy"`
}

ConnectionConfig holds GRPC client configuration

func (*ConnectionConfig) Validate

func (c *ConnectionConfig) Validate() error

type ConnectionsConfig

type ConnectionsConfig map[string]*ConnectionConfig

func (*ConnectionsConfig) Validate

func (c *ConnectionsConfig) Validate() error

type Container

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

Container is a simple container for holding named GRPC connections.

func NewContainer

func NewContainer() *Container

func (*Container) Connect

func (cont *Container) Connect(name string, cfg *ConnectionConfig) error

Connect creates a new named GRPC connection

func (*Container) Get

func (cont *Container) Get(name string) grpc.ClientConnInterface

Get gets connection from a container

type ExponentialBackoffConfig

type ExponentialBackoffConfig struct {
	// Base delay is the length of the first delay in the retry cycle
	BaseDelay time.Duration `mapstructure:"base_delay"`

	// Jitter fraction
	Jitter float64 `mapstructure:"jitter"`

	// MaxAttempts is the cap for retry attempts. Set 0 to disable
	MaxAttempts int `mapstructure:"max_attempts"`
}

func (*ExponentialBackoffConfig) Validate

func (c *ExponentialBackoffConfig) Validate() error

type KeepaliveConfig

type KeepaliveConfig struct {
	Time                time.Duration
	Timeout             time.Duration
	PermitWithoutStream bool `mapstructure:"permit_without_stream"`
}

KeepaliveConfig holds grpc keepalive balancing options. see keepalive.ClientParameters for details.

type LinearBackoffConfig

type LinearBackoffConfig struct {
	// Delay is the delay length between retries
	Delay time.Duration

	// Jitter fraction
	Jitter float64 `mapstructure:"jitter"`

	// MaxAttempts is the cap for retry attempts. Set 0 to disable
	MaxAttempts int
}

func (*LinearBackoffConfig) Validate

func (c *LinearBackoffConfig) Validate() error

type RetryConfig

type RetryConfig struct {
	ExponentialBackoff *ExponentialBackoffConfig `mapstructure:"exponential"`
	LinearBackoff      *LinearBackoffConfig      `mapstructure:"linear"`
	Codes              []codes.Code              `mapstructure:"codes"`
}

func NewDefaultRetryConfig

func NewDefaultRetryConfig() *RetryConfig

func (*RetryConfig) Validate

func (c *RetryConfig) Validate() error

type TLSConfig added in v1.2.0

type TLSConfig struct {
	Enabled bool
}

Jump to

Keyboard shortcuts

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