Documentation ¶
Overview ¶
Package conncheck checks if a connection is alive.
Index ¶
- Variables
- type ConnChecker
- func (c *ConnChecker) AddAndRunSender(clusterID, ip string, updateCallback UpdateFunc)
- func (c *ConnChecker) DelAndStopSender(clusterID string)
- func (c *ConnChecker) GetConnected(clusterID string) (bool, error)
- func (c *ConnChecker) GetLatency(clusterID string) (time.Duration, error)
- func (c *ConnChecker) RunReceiver()
- func (c *ConnChecker) RunReceiverDisconnectObserver()
- type Msg
- type MsgTypes
- type Peer
- type Receiver
- type Sender
- type UpdateFunc
Constants ¶
This section is empty.
Variables ¶
var ( // PingLossThreshold is the number of lost packets after which the connection check is considered as failed. PingLossThreshold uint // PingInterval is the interval at which the ping is sent. PingInterval time.Duration )
Functions ¶
This section is empty.
Types ¶
type ConnChecker ¶
type ConnChecker struct {
// contains filtered or unexported fields
}
ConnChecker is a struct that holds the receiver and senders.
func NewConnChecker ¶
func NewConnChecker() (*ConnChecker, error)
NewConnChecker creates a new ConnChecker.
func (*ConnChecker) AddAndRunSender ¶
func (c *ConnChecker) AddAndRunSender(clusterID, ip string, updateCallback UpdateFunc)
AddAndRunSender create a new sender and runs it.
func (*ConnChecker) DelAndStopSender ¶
func (c *ConnChecker) DelAndStopSender(clusterID string)
DelAndStopSender stops and deletes a sender. If sender has been already stoped and deleted is a no-op function.
func (*ConnChecker) GetConnected ¶
func (c *ConnChecker) GetConnected(clusterID string) (bool, error)
GetConnected returns the connection status with clusterID.
func (*ConnChecker) GetLatency ¶
func (c *ConnChecker) GetLatency(clusterID string) (time.Duration, error)
GetLatency returns the latency with clusterID.
func (*ConnChecker) RunReceiver ¶
func (c *ConnChecker) RunReceiver()
RunReceiver runs the receiver.
func (*ConnChecker) RunReceiverDisconnectObserver ¶
func (c *ConnChecker) RunReceiverDisconnectObserver()
RunReceiverDisconnectObserver runs the receiver disconnect observer.
type Msg ¶
type Msg struct { ClusterID string `json:"clusterID"` MsgType MsgTypes `json:"msgType"` TimeStamp time.Time `json:"timeStamp"` }
Msg represents a message sent between two nodes.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver is a receiver for conncheck messages.
func NewReceiver ¶
NewReceiver creates a new conncheck receiver.
func (*Receiver) InitPeer ¶
func (r *Receiver) InitPeer(clusterID string, updateCallback UpdateFunc) error
InitPeer initializes a peer.
func (*Receiver) ReceivePong ¶
ReceivePong receives a PONG message.
func (*Receiver) RunDisconnectObserver ¶
func (r *Receiver) RunDisconnectObserver()
RunDisconnectObserver starts the disconnect observer.