keepalive

package
v0.85.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ProtocolName        = "keep-alive"
	ProtocolId   uint16 = 8

	// Time between keep-alive probes, in seconds
	DefaultKeepAlivePeriod = 60

	// Timeout for keep-alive responses, in seconds
	DefaultKeepAliveTimeout = 10
)
View Source
const (
	MessageTypeKeepAlive         = 0
	MessageTypeKeepAliveResponse = 1
	MessageTypeDone              = 2
)

Variables

View Source
var (
	StateClient = protocol.NewState(1, "Client")
	StateServer = protocol.NewState(2, "Server")
	StateDone   = protocol.NewState(3, "Done")
)

Functions

func NewMsgFromCbor

func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)

Types

type CallbackContext added in v0.78.0

type CallbackContext struct {
	ConnectionId connection.ConnectionId
	Client       *Client
	Server       *Server
}

Callback context

type Client

type Client struct {
	*protocol.Protocol
	// contains filtered or unexported fields
}

func NewClient

func NewClient(protoOptions protocol.ProtocolOptions, cfg *Config) *Client

func (*Client) Start

func (c *Client) Start()

type Config

type Config struct {
	KeepAliveFunc         KeepAliveFunc
	KeepAliveResponseFunc KeepAliveResponseFunc
	DoneFunc              DoneFunc
	Timeout               time.Duration
	Period                time.Duration
	Cookie                uint16
}

func NewConfig

func NewConfig(options ...KeepAliveOptionFunc) Config

type DoneFunc

type DoneFunc func(CallbackContext) error

type KeepAlive

type KeepAlive struct {
	Client *Client
	Server *Server
}

func New

func New(protoOptions protocol.ProtocolOptions, cfg *Config) *KeepAlive

type KeepAliveFunc

type KeepAliveFunc func(CallbackContext, uint16) error

Callback function types

type KeepAliveOptionFunc

type KeepAliveOptionFunc func(*Config)

func WithCookie added in v0.65.0

func WithCookie(cookie uint16) KeepAliveOptionFunc

func WithDoneFunc

func WithDoneFunc(doneFunc DoneFunc) KeepAliveOptionFunc

func WithKeepAliveFunc

func WithKeepAliveFunc(keepAliveFunc KeepAliveFunc) KeepAliveOptionFunc

func WithKeepAliveResponseFunc

func WithKeepAliveResponseFunc(
	keepAliveResponseFunc KeepAliveResponseFunc,
) KeepAliveOptionFunc

func WithPeriod

func WithPeriod(period time.Duration) KeepAliveOptionFunc

func WithTimeout

func WithTimeout(timeout time.Duration) KeepAliveOptionFunc

type KeepAliveResponseFunc

type KeepAliveResponseFunc func(CallbackContext, uint16) error

type MsgDone

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone

func NewMsgDone() *MsgDone

type MsgKeepAlive

type MsgKeepAlive struct {
	protocol.MessageBase
	Cookie uint16
}

func NewMsgKeepAlive

func NewMsgKeepAlive(cookie uint16) *MsgKeepAlive

type MsgKeepAliveResponse

type MsgKeepAliveResponse struct {
	protocol.MessageBase
	Cookie uint16
}

func NewMsgKeepAliveResponse

func NewMsgKeepAliveResponse(cookie uint16) *MsgKeepAliveResponse

type Server

type Server struct {
	*protocol.Protocol
	// contains filtered or unexported fields
}

func NewServer

func NewServer(protoOptions protocol.ProtocolOptions, cfg *Config) *Server

Jump to

Keyboard shortcuts

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