Documentation
¶
Index ¶
- type CPUResources
- type Cache
- type Collector
- type ComponentState
- type ComponentStatus
- type DiskIO
- type DiskResources
- type DockerChecker
- type DockerCheckerOptions
- type HealthChecker
- type MemoryResources
- type NetworkInterface
- type NetworkResources
- type NodeCapacity
- type NodeComponents
- type NodeResources
- type NodeStatus
- type Options
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CPUResources ¶
type CPUResources struct {
TotalMCores float64 `json:"total_mcores"`
FreeMCores float64 `json:"free_mcores"`
Load1 float64 `json:"load_1m"`
}
CPUResources contains CPU capacity and utilization metrics.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores the latest lifecycle status snapshot for reuse. Stores typed NodeStatus for compile-time safety; use LatestStatus() to retrieve the cached status.
Cache methods are nil-safe: calling Store or LatestStatus on a nil Cache is a no-op, allowing optional cache usage without nil checks.
func (*Cache) LatestStatus ¶
func (c *Cache) LatestStatus() (NodeStatus, bool)
LatestStatus returns a copy of the cached NodeStatus when available.
func (*Cache) Store ¶
func (c *Cache) Store(status NodeStatus)
Store replaces the cached status with the provided NodeStatus.
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector gathers node lifecycle data for status endpoints and heartbeats.
func NewCollector ¶
NewCollector constructs a lifecycle collector with the supplied options.
type ComponentState ¶
type ComponentState string
ComponentState represents the health state of a subsystem.
const ( StateOK ComponentState = "ok" StateDegraded ComponentState = "degraded" StateError ComponentState = "error" StateUnknown ComponentState = "unknown" )
type ComponentStatus ¶
type ComponentStatus struct {
State ComponentState `json:"state"`
Message string `json:"message,omitempty"`
Version string `json:"version,omitempty"`
Details map[string]any `json:"details,omitempty"`
CheckedAt time.Time `json:"checked_at"`
}
ComponentStatus describes the outcome of a subsystem health probe.
func (ComponentStatus) MarshalJSON ¶
func (cs ComponentStatus) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler for ComponentStatus.
type DiskIO ¶
type DiskIO struct {
ReadMBPerSec float64 `json:"read_mb_per_sec"`
WriteMBPerSec float64 `json:"write_mb_per_sec"`
ReadIOPS float64 `json:"read_iops"`
WriteIOPS float64 `json:"write_iops"`
InitialSample bool `json:"initial_sample,omitempty"`
}
DiskIO contains disk I/O throughput and IOPS metrics.
type DiskResources ¶
type DiskResources struct {
TotalMB float64 `json:"total_mb"`
FreeMB float64 `json:"free_mb"`
IO DiskIO `json:"io"`
}
DiskResources contains disk capacity, utilization, and I/O metrics.
type DockerChecker ¶
type DockerChecker struct {
// contains filtered or unexported fields
}
DockerChecker probes the Docker Engine for availability and version info. It uses the moby Engine v29 SDK (github.com/moby/moby/client) for Ping and Info calls to determine daemon availability and running container state.
Engine v29 Ping/Info Field Reconciliation ¶
The checker exposes a stable set of Details keys across Engine v28 and v29:
api_version - from PingResult.APIVersion (e.g., "1.44", "1.45") os_type - from PingResult.OSType (e.g., "linux", "windows") containers_running - from system.Info.ContainersRunning driver - from system.Info.Driver (e.g., "overlay2")
ComponentStatus.Version is set from system.Info.ServerVersion, which returns the Docker daemon version (e.g., "27.0.0", "29.0.0").
These fields are stable across Docker Engine v28.x and v29.x. The moby SDK types (client.PingResult, system.Info) have not changed the field names or semantics for these core fields between versions.
func NewDockerChecker ¶
func NewDockerChecker(opts DockerCheckerOptions) (*DockerChecker, error)
NewDockerChecker constructs a Docker checker using the environment or provided client.
func (*DockerChecker) Check ¶
func (c *DockerChecker) Check(ctx context.Context) ComponentStatus
Check reports Docker health by issuing ping and info calls. Uses the moby Engine v29 SDK for daemon health checks:
- Ping verifies daemon connectivity and retrieves API version.
- Info retrieves server version, container count, and storage driver.
ComponentStatus.State is set to OK, Degraded, or Error based on results.
Stable Details Keys (Engine v28/v29) ¶
The following Details keys are populated and remain stable across versions:
api_version - Docker API version from Ping (string, e.g., "1.44") os_type - OS type from Ping (string, "linux" or "windows") containers_running - Running container count from Info (int) driver - Storage driver from Info (string, e.g., "overlay2")
Version is set from system.Info.ServerVersion (e.g., "29.0.0").
func (*DockerChecker) Close ¶
func (c *DockerChecker) Close() error
Close releases the underlying Docker client.
type DockerCheckerOptions ¶
type DockerCheckerOptions struct {
Client dockerAPI
Host string
Timeout time.Duration
Clock func() time.Time
}
DockerCheckerOptions configure the Docker health checker.
type HealthChecker ¶
type HealthChecker interface {
Check(ctx context.Context) ComponentStatus
}
HealthChecker reports the current state of a subsystem.
type MemoryResources ¶
MemoryResources contains memory capacity and utilization metrics.
type NetworkInterface ¶
type NetworkInterface struct {
RXBytesPerSec float64 `json:"rx_bytes_per_sec"`
TXBytesPerSec float64 `json:"tx_bytes_per_sec"`
RXPacketsPerSec float64 `json:"rx_packets_per_sec"`
TXPacketsPerSec float64 `json:"tx_packets_per_sec"`
InitialSample bool `json:"initial_sample,omitempty"`
}
NetworkInterface contains per-interface network throughput metrics.
type NetworkResources ¶
type NetworkResources struct {
RXBytesPerSec float64 `json:"rx_bytes_per_sec"`
TXBytesPerSec float64 `json:"tx_bytes_per_sec"`
RXPacketsPerSec float64 `json:"rx_packets_per_sec"`
TXPacketsPerSec float64 `json:"tx_packets_per_sec"`
InitialSample bool `json:"initial_sample,omitempty"`
Interfaces map[string]NetworkInterface `json:"interfaces,omitempty"`
}
NetworkResources contains network throughput metrics and per-interface details.
type NodeCapacity ¶
type NodeCapacity struct {
CPUFreeMillis domaintypes.CPUmilli `json:"cpu_free_millis"`
CPUTotalMillis domaintypes.CPUmilli `json:"cpu_total_millis"`
MemFreeBytes domaintypes.Bytes `json:"mem_free_bytes"`
MemTotalBytes domaintypes.Bytes `json:"mem_total_bytes"`
DiskFreeBytes domaintypes.Bytes `json:"disk_free_bytes"`
DiskTotalBytes domaintypes.Bytes `json:"disk_total_bytes"`
Heartbeat time.Time `json:"heartbeat"`
}
NodeCapacity represents available node resources for scheduling.
func (NodeCapacity) MarshalJSON ¶
func (c NodeCapacity) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler for NodeCapacity.
type NodeComponents ¶
type NodeComponents struct {
Docker ComponentStatus `json:"docker"`
Gate ComponentStatus `json:"gate"`
}
NodeComponents contains health status for node subsystems.
type NodeResources ¶
type NodeResources struct {
CPU CPUResources `json:"cpu"`
Memory MemoryResources `json:"memory"`
Disk DiskResources `json:"disk"`
Network NetworkResources `json:"network"`
}
NodeResources aggregates CPU, memory, disk, and network resource snapshots.
type NodeStatus ¶
type NodeStatus struct {
State ComponentState `json:"state"`
Timestamp time.Time `json:"timestamp"`
Heartbeat time.Time `json:"heartbeat"`
Role string `json:"role"`
NodeID domaintypes.NodeID `json:"node_id"`
Hostname string `json:"hostname"`
Resources NodeResources `json:"resources"`
Components NodeComponents `json:"components"`
ResourceWarning string `json:"resource_warning,omitempty"`
}
NodeStatus contains the complete lifecycle status snapshot for a node.
func (NodeStatus) MarshalJSON ¶
func (s NodeStatus) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler for NodeStatus.
type Options ¶
type Options struct {
Role string
NodeID domaintypes.NodeID
Hostname func() (string, error)
Docker HealthChecker
Gate HealthChecker
Clock func() time.Time
IgnoreInterfaces []string
}
Options configure the lifecycle collector.
type Snapshot ¶
type Snapshot struct {
Status NodeStatus
Capacity NodeCapacity
}
Snapshot aggregates typed status and capacity payloads.