keepalive

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeepAliveDeadlineExceeded = fmt.Errorf("keepalive: %w", context.DeadlineExceeded)

ErrKeepAliveDeadlineExceeded occurs during waiting for pong response

Functions

This section is empty.

Types

type CfgOpt

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

func WithConfig

func WithConfig(config Config) *CfgOpt

type ClientConn

type ClientConn interface {
	Context() context.Context
	Ping(context.Context) error
	Close() error
}

type Config

type Config struct {
	// Interval between two success pings
	Interval time.Duration
	// WaitForPong how long it will waits for pong response.
	WaitForPong time.Duration
	// NewRetryPolicy creates retry policy for the connection when ping fails.
	NewRetryPolicy RetryFuncFactory
}

Config KeepAlive config

func MakeConfig

func MakeConfig(connTimeout time.Duration) Config

MakeConfig creates a policy that detects dropped connections within the connTimeout limit while attempting to make 3 pings during that period.

type KeepAlive

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

func New

func New(opts ...Option) *KeepAlive

func (*KeepAlive) Run

func (k *KeepAlive) Run(c ClientConn) error

type Option

type Option interface {
	// contains filtered or unexported methods
}

A Option sets options such as config etc.

type RetryFunc

type RetryFunc = func() (when time.Time, err error)

type RetryFuncFactory

type RetryFuncFactory = func() RetryFunc

Jump to

Keyboard shortcuts

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