runtime

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceContainer = "container"
	ResourceService   = "service"
	ResourceNode      = "node"
)

Resource types for RuntimeEvent.

Variables

This section is empty.

Functions

func Register

func Register(name string, f Factory)

Register adds a named runtime factory. Called from init() in runtime packages.

Types

type Factory

type Factory func(ctx context.Context, logger *slog.Logger) (Runtime, error)

Factory creates a Runtime from configuration and logger.

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
	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

func Detect(ctx context.Context, logger *slog.Logger) (Runtime, error)

Detect auto-detects the container runtime or uses the MAINTENANT_RUNTIME override. Detection order: env override → KUBERNETES_SERVICE_HOST → KUBECONFIG → Docker socket.

type RuntimeEvent

type RuntimeEvent struct {
	Action       string
	ExternalID   string
	Name         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.

Jump to

Keyboard shortcuts

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