keepalive

package
v0.38.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PROTOCOL_NAME        = "keep-alive"
	PROTOCOL_ID   uint16 = 8

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

	// Timeout for keep-alive responses, in seconds
	DEFAULT_KEEP_ALIVE_TIMEOUT = 10
)
View Source
const (
	MESSAGE_TYPE_KEEP_ALIVE          = 0
	MESSAGE_TYPE_KEEP_ALIVE_RESPONSE = 1
	MESSAGE_TYPE_DONE                = 2
)

Variables

View Source
var (
	STATE_CLIENT = protocol.NewState(1, "Client")
	STATE_SERVER = protocol.NewState(2, "Server")
	STATE_DONE   = protocol.NewState(3, "Done")
)

Functions

func NewMsgFromCbor

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

Types

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
}

func NewConfig

func NewConfig(options ...KeepAliveOptionFunc) Config

type DoneFunc

type DoneFunc func() 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(uint16) error

Callback function types

type KeepAliveOptionFunc

type KeepAliveOptionFunc func(*Config)

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(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