Documentation ¶
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type CallbackContext
- type Client
- type Config
- type DoneFunc
- type KeepAlive
- type KeepAliveFunc
- type KeepAliveOptionFunc
- func WithCookie(cookie uint16) KeepAliveOptionFunc
- func WithDoneFunc(doneFunc DoneFunc) KeepAliveOptionFunc
- func WithKeepAliveFunc(keepAliveFunc KeepAliveFunc) KeepAliveOptionFunc
- func WithKeepAliveResponseFunc(keepAliveResponseFunc KeepAliveResponseFunc) KeepAliveOptionFunc
- func WithPeriod(period time.Duration) KeepAliveOptionFunc
- func WithTimeout(timeout time.Duration) KeepAliveOptionFunc
- type KeepAliveResponseFunc
- type MsgDone
- type MsgKeepAlive
- type MsgKeepAliveResponse
- type Server
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") )
View Source
var StateMap = protocol.StateMap{ StateClient: protocol.StateMapEntry{ Agency: protocol.AgencyClient, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeKeepAlive, NewState: StateServer, }, { MsgType: MessageTypeDone, NewState: StateDone, }, }, }, StateServer: protocol.StateMapEntry{ Agency: protocol.AgencyServer, Transitions: []protocol.StateTransition{ { MsgType: MessageTypeKeepAliveResponse, NewState: StateClient, }, }, }, StateDone: protocol.StateMapEntry{ Agency: protocol.AgencyNone, }, }
Functions ¶
Types ¶
type CallbackContext ¶ added in v0.78.0
type CallbackContext struct { ConnectionId connection.ConnectionId Client *Client Server *Server }
Callback context
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 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
Click to show internal directories.
Click to hide internal directories.