connection

package
v0.0.0-...-c939168 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBackoffInterval    = 500 * time.Millisecond
	DefaultBackoffMultiplier  = 1.5
	DefaultBackoffMaxInterval = 60 * time.Second
	DefaultBackoffMaxTime     = 15 * time.Minute
)

Default backoff configuration.

View Source
const (
	DefaultKeepAliveInterval = 25 * time.Second
)

Default keepAlive configuration.

Variables

This section is empty.

Functions

func SetDefaultKeepAlive

func SetDefaultKeepAlive(conn net.Conn) error

Types

type Backoff

type Backoff interface {
	// Next returns the duration to sleep before retrying to reconnect.
	// If the returned value is negative, the retry is aborted.
	NextBackOff() time.Duration

	// Reset is used to signal a reconnection was successful and next
	// call to Next should return desired time duration for 1st reconnection
	// attempt.
	Reset()
}

Backoff defines behavior of staggering reconnection retries.

type BackoffConfig

type BackoffConfig struct {
	Interval    time.Duration `yaml:"interval"`
	Multiplier  float64       `yaml:"multiplier"`
	MaxInterval time.Duration `yaml:"max_interval"`
	MaxTime     time.Duration `yaml:"max_time"`
}

BackoffConfig defines behavior of staggering reconnection retries.

func NewDefaultBackoffConfig

func NewDefaultBackoffConfig() *BackoffConfig

type KeepAliveConfig

type KeepAliveConfig struct {
	KeepAliveInterval time.Duration `yaml:"interval"`
}

KeepAliveConfig defines if and how the keepAlive package is sent.

func NewDefaultKeepAliveConfig

func NewDefaultKeepAliveConfig() *KeepAliveConfig

func Parse

func Parse(interval string) (*KeepAliveConfig, error)

func (*KeepAliveConfig) Set

func (k *KeepAliveConfig) Set(conn net.Conn) error

func (*KeepAliveConfig) String

func (k *KeepAliveConfig) String() string

Jump to

Keyboard shortcuts

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