Documentation
¶
Index ¶
Constants ¶
const ( ResourceContainer = "container" ResourceService = "service" ResourceNode = "node" )
Resource types for RuntimeEvent.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HealthInfo ¶
type HealthInfo struct {
HasHealthCheck bool
Status string // "healthy", "unhealthy", "starting", "none"
FailingStreak int
LastOutput string
}
HealthInfo holds runtime-agnostic health check information.
type RawStats ¶
type RawStats struct {
CPUPercent float64
MemUsed int64
MemLimit int64
NetRxBytes int64 // -1 if unavailable
NetTxBytes int64 // -1 if unavailable
BlockReadBytes int64 // -1 if unavailable
BlockWriteBytes int64 // -1 if unavailable
Timestamp time.Time
}
RawStats is a runtime-agnostic resource snapshot. Fields set to -1 indicate the metric is unavailable for this runtime.
type Runtime ¶
type Runtime interface {
// Lifecycle
Connect(ctx context.Context) error
// TryConnect attempts a single bounded connection (~3s). Non-fatal: returns error without retrying.
TryConnect(ctx context.Context) error
IsConnected() bool
SetDisconnected()
Close() error
// Identity
Name() string // "docker" or "kubernetes"
// Discovery
DiscoverAll(ctx context.Context) ([]*container.Container, error)
// Events
StreamEvents(ctx context.Context) <-chan RuntimeEvent
// Stats
StatsSnapshot(ctx context.Context, externalID string) (*RawStats, error)
// Logs
FetchLogs(ctx context.Context, externalID string, lines int, timestamps bool) ([]string, error)
StreamLogs(ctx context.Context, externalID string, lines int, timestamps bool) (io.ReadCloser, error)
// Health
GetHealthInfo(ctx context.Context, externalID string) (*HealthInfo, error)
}
Runtime abstracts the container orchestration platform. Implementations: docker.Runtime, kubernetes.Runtime.
func Detect ¶
Detect auto-detects the container runtime or uses the MAINTENANT_RUNTIME env override. Detection order: env override → KUBERNETES_SERVICE_HOST → KUBECONFIG → Docker socket.
func DetectWithOverride ¶ added in v1.3.0
DetectWithOverride is like Detect but allows the caller to pass an explicit override (e.g. from a CLI flag). When override is empty, the MAINTENANT_RUNTIME env variable is consulted as a fallback.
type RuntimeEvent ¶
type RuntimeEvent struct {
Action string
ExternalID string
Name string
Image string
ExitCode string
HealthStatus string
ErrorDetail string
ResourceType string // "container", "service", or "node"
Timestamp time.Time
Labels map[string]string
}
RuntimeEvent is a normalized state change from any runtime.