peer

package
v0.0.0-...-5ef962b Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeepaliveMessageLen = 9
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Keepalive

type Keepalive struct {
	Priority     uint8
	Interval     uint32
	DeadInterval uint32
}

Keepalive defines a message which gets exchanged between two peers

func (*Keepalive) MarshalBinary

func (ka *Keepalive) MarshalBinary() []byte

func (*Keepalive) UnmarshalBinary

func (ka *Keepalive) UnmarshalBinary(b []byte) error

type KeepaliveStats

type KeepaliveStats struct {
	TotalMmisses   int
	LastChangeUp   int64
	LastChangeDown int64
}

type Monitor

type Monitor interface {
	// GetPeerState(string) PeerState
	GetMonitorCh() chan *MonitorMessage
	Stop()
}

func SetupMonitorForRemotePeer

func SetupMonitorForRemotePeer(la string, port int, rPeers ...string) (Monitor, error)

SetupMonitorForRemotePeer sets up a keep alive mechanism between a local and remote peers, returned Monitor interface allows get a state of a particular peer by specifying its id, or get a notification channel for changes of a remote peer states.

type MonitorMessage

type MonitorMessage struct {
	RemotePeer string
	PeerState  PeerState
}

type Peer

type Peer interface {
	Start()
	Stop()
	GetSessionStateChangeCh() chan *SessionState
	GetRemoteAddr() string
	Alive() bool
}

Manager defines methods to control and query a keepalive process

func NewPeer

func NewPeer(la string, port int, ra string, state chan *SessionState) (Peer, error)

type PeerState

type PeerState uint8
const (
	PeerUp PeerState = iota + 1
	PeerDown
)

func (PeerState) String

func (ps PeerState) String() string

type SessionState

type SessionState struct {
	RemotePeer string
	PeerState  PeerState
}

Jump to

Keyboard shortcuts

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