Documentation ¶
Overview ¶
Package conncheck checks if a connection is alive.
Index ¶
- type ConnChecker
- func (c *ConnChecker) AddSender(ctx context.Context, clusterID, ip string, updateCallback UpdateFunc) error
- 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(ctx context.Context)
- func (c *ConnChecker) RunReceiverDisconnectObserver(ctx context.Context)
- func (c *ConnChecker) RunSender(clusterID string)
- type DuplicateError
- type Msg
- type MsgTypes
- type Options
- type Peer
- type Receiver
- type Sender
- type UpdateFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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(opts *Options) (*ConnChecker, error)
NewConnChecker creates a new ConnChecker.
func (*ConnChecker) AddSender ¶
func (c *ConnChecker) AddSender(ctx context.Context, clusterID, ip string, updateCallback UpdateFunc) error
AddSender adds a sender.
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(ctx context.Context)
RunReceiver runs the receiver.
func (*ConnChecker) RunReceiverDisconnectObserver ¶
func (c *ConnChecker) RunReceiverDisconnectObserver(ctx context.Context)
RunReceiverDisconnectObserver runs the receiver disconnect observer.
func (*ConnChecker) RunSender ¶
func (c *ConnChecker) RunSender(clusterID string)
RunSender runs a sender.
type DuplicateError ¶
type DuplicateError struct {
Err error
}
DuplicateError is an error type for ConnChecker. It is returned when an already present sender is added.
func NewDuplicateError ¶
func NewDuplicateError(clusterID string) *DuplicateError
NewDuplicateError returns a new DuplicateError.
func (DuplicateError) Error ¶
func (e DuplicateError) Error() string
Error returns the error message.
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 Options ¶
type Options struct { // PingPort is the port used for the ping check. PingPort int // PingBufferSize is the size of the buffer used for the ping check. PingBufferSize uint // 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 }
Options contains the options for the wireguard interface.
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 ¶
RunDisconnectObserver starts the disconnect observer.