Documentation
¶
Overview ¶
Package nodes tracks live node state (§5.6). Heartbeats and metrics stay in memory; only status transitions are written to SQLite (D5).
Index ¶
- Constants
- type Info
- type Metrics
- type Registry
- func (r *Registry) Added(n store.Node)
- func (r *Registry) Connected(ctx context.Context, id string, info Info)
- func (r *Registry) Disconnected(ctx context.Context, id string)
- func (r *Registry) Get(id string) (View, bool)
- func (r *Registry) Heartbeat(ctx context.Context, id string, m Metrics)
- func (r *Registry) List() []View
- func (r *Registry) Load(ctx context.Context) error
- func (r *Registry) Removed(id string)
- func (r *Registry) Run(ctx context.Context)
- func (r *Registry) SetPool(ctx context.Context, id, poolID string, protected bool)
- func (r *Registry) SetSchedulable(ctx context.Context, id string, on, draining bool)
- type View
Constants ¶
const ( HeartbeatInterval = 5 * time.Second SuspectAfter = 20 * time.Second NotReadyAfter = 60 * time.Second )
Thresholds from §5.6.
const TopicNode = "node.updated"
TopicNode carries a View on every status change and heartbeat.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct {
Hostname string `json:"hostname"`
OS string `json:"os"`
Kernel string `json:"kernel"`
Arch string `json:"arch"`
CPUCores int `json:"cpuCores"`
MemoryBytes uint64 `json:"memoryBytes"`
DiskBytes uint64 `json:"diskBytes"`
DockerVersion string `json:"dockerVersion"`
AgentVersion string `json:"agentVersion"`
}
type Metrics ¶
type Metrics struct {
CPUPercent float64 `json:"cpuPercent"`
MemoryUsedBytes uint64 `json:"memoryUsedBytes"`
MemoryTotalBytes uint64 `json:"memoryTotalBytes"`
DiskUsedBytes uint64 `json:"diskUsedBytes"`
DiskTotalBytes uint64 `json:"diskTotalBytes"`
Load1 float64 `json:"load1"`
Load5 float64 `json:"load5"`
Load15 float64 `json:"load15"`
NetRxBytes uint64 `json:"netRxBytes"`
NetTxBytes uint64 `json:"netTxBytes"`
UptimeSeconds int64 `json:"uptimeSeconds"`
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Load ¶
Load fills the registry from SQLite at startup. Every node starts disconnected; heartbeat timeouts then apply from each node's last-seen time, so nodes that don't reconnect go Suspect and then Not ready. The stored last-seen time is only written on transitions, and agents need a moment to reconnect, so timeouts count from the controller's start at the earliest: restarting the controller never reschedules tasks.
type View ¶
type View struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
StatusAt time.Time `json:"statusAt"`
Connected bool `json:"connected"`
LastSeenAt *time.Time `json:"lastSeenAt"`
CreatedAt time.Time `json:"createdAt"`
Info Info `json:"info"`
Metrics *Metrics `json:"metrics"`
// Schedulable allows new tasks (§6.4: off for the controller by default).
Schedulable bool `json:"schedulable"`
// Draining moves the node's tasks to other nodes.
Draining bool `json:"draining"`
// PoolID is the node's pool ("" outside any pool, §6.5).
PoolID string `json:"poolId"`
ScaleInProtected bool `json:"scaleInProtected"`
}
View is a node as the API and dashboard see it.