Documentation
¶
Overview ¶
Package mesh is SCAFFOLDED — gossip-based peer discovery scaffolding. Not wired into the stable operator path.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ListenAddr is the UDP address for gossip (default ":42426").
ListenAddr string `yaml:"listen_addr" json:"listen_addr"`
// GossipInterval is how often we broadcast our peer list.
GossipInterval time.Duration `yaml:"gossip_interval" json:"gossip_interval"`
// SuspectTimeout is how long before a silent peer becomes suspect.
SuspectTimeout time.Duration `yaml:"suspect_timeout" json:"suspect_timeout"`
// DeadTimeout is how long a suspect peer stays before eviction.
DeadTimeout time.Duration `yaml:"dead_timeout" json:"dead_timeout"`
// MaxPeers caps the mesh to prevent unbounded growth.
MaxPeers int `yaml:"max_peers" json:"max_peers"`
SharedSecret string `yaml:"shared_secret" json:"shared_secret"`
// FanOut is how many random peers receive each gossip round.
FanOut int `yaml:"fan_out" json:"fan_out"`
}
Config controls mesh behavior.
type Mesh ¶
type Mesh struct {
// Callbacks for integration with daemon cache.
OnPeerJoin func(Peer)
OnPeerLeave func(Peer)
OnPeerSuspect func(Peer)
// contains filtered or unexported fields
}
Mesh manages peer discovery and gossip protocol.
func (*Mesh) ActivePeers ¶
ActivePeers returns only peers that are verified or trusted.
func (*Mesh) AddSeed ¶
AddSeed injects a known seed peer (from nodes.yaml). Seed peers start as Trusted.
type Peer ¶
type Peer struct {
Name string `json:"name"`
Hostname string `json:"hostname"`
Port int `json:"port"`
StableID string `json:"stable_id"`
State PeerState `json:"state"`
Source string `json:"source"` // "config", "gossip", "mdns", "peer-exchange"
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
MissedPings int `json:"missed_pings"`
Generation uint64 `json:"generation"` // Lamport-style monotonic counter
}
Peer represents a node in the mesh.
type PeerState ¶
type PeerState int
PeerState tracks a discovered peer's lifecycle.
const ( // PeerDiscovered means we heard about this node but haven't verified it. PeerDiscovered PeerState = iota // PeerVerified means SSH probe succeeded at least once. PeerVerified // PeerTrusted means the operator explicitly promoted this node. PeerTrusted // PeerSuspect means the node missed consecutive heartbeats. PeerSuspect // PeerDead means the node has been unreachable beyond the eviction window. PeerDead )
Click to show internal directories.
Click to hide internal directories.