Documentation
¶
Overview ¶
Package machinediagnostics implements the portable, user-readable diagnostics contract produced by the machine inactivity daemon.
Index ¶
- Constants
- func DiagnosticsDir(root string) string
- func EncodeCursor(sessionID string, sequence uint64) string
- func ValidateCursor(value string) error
- func WriteLocator(path string, locator Locator) error
- type Availability
- type CursorInfo
- type CursorState
- type DaemonHealth
- type DaemonState
- type DiagnosticError
- type Event
- type EventType
- type Freshness
- type Level
- type Locator
- type Options
- type ReadOptions
- type ReadResponse
- type ReaderIdentity
- type Recorder
- type RuntimeLock
- type Sanitizer
- type ShutdownCandidate
- type Status
- type Store
- type WorkspaceEvaluationState
- type WorkspaceStatus
Constants ¶
View Source
const ( DefaultRuntimeLockPath = "/run/devsy/agent-daemon.lock" RuntimeLockPathEnv = "DEVSY_DAEMON_RUNTIME_LOCK_PATH" )
View Source
const ( SchemaVersion = 1 MaxRemoteEventBytes = 5 * 1024 * 1024 MaxSegmentBytes = 512 * 1024 MaxEventMessageBytes = 4 * 1024 MaxReadEvents = 1000 DefaultReadEvents = 100 )
View Source
const DefaultLocatorPath = "/run/devsy/agent-daemon.json"
Variables ¶
This section is empty.
Functions ¶
func DiagnosticsDir ¶
func EncodeCursor ¶
func ValidateCursor ¶
ValidateCursor keeps cursor encoding opaque to callers while allowing public command surfaces to reject malformed input before opening a remote session.
func WriteLocator ¶
Types ¶
type Availability ¶
type Availability string
const ( AvailabilityAvailable Availability = "available" AvailabilityNotInitialized Availability = "not_initialized" AvailabilityPermissionDenied Availability = "permission_denied" AvailabilityCorrupt Availability = "corrupt" )
type CursorInfo ¶
type CursorInfo struct {
Next string `json:"next,omitempty"`
State CursorState `json:"state"`
Reason string `json:"reason,omitempty"`
}
type CursorState ¶
type CursorState string
const ( CursorOK CursorState = "ok" CursorGap CursorState = "gap" CursorReset CursorState = "reset" CursorNone CursorState = "none" )
type DaemonHealth ¶
type DaemonHealth string
const ( DaemonHealthy DaemonHealth = "healthy" DaemonDegraded DaemonHealth = "degraded" )
type DaemonState ¶
type DaemonState string
const ( DaemonStarting DaemonState = "starting" DaemonRunning DaemonState = "running" DaemonStopping DaemonState = "stopping" )
type DiagnosticError ¶
type Event ¶
type Event struct {
SchemaVersion int `json:"schemaVersion"`
SessionID string `json:"sessionId"`
Sequence uint64 `json:"sequence"`
Timestamp time.Time `json:"timestamp"`
Level Level `json:"level"`
Type EventType `json:"type"`
WorkspaceID string `json:"workspaceId,omitempty"`
Message string `json:"message"`
ErrorCode string `json:"errorCode,omitempty"`
}
type EventType ¶
type EventType string
const ( EventDaemonStarted EventType = "daemon.started" EventDaemonReady EventType = "daemon.ready" EventDaemonStopping EventType = "daemon.stopping" EventWorkspaceDiscovered EventType = "workspace.discovered" EventWorkspaceRemoved EventType = "workspace.removed" EventWorkspaceConfigErr EventType = "workspace.config_error" EventIdleDeadline EventType = "workspace.idle_deadline_reached" EventShutdownStarted EventType = "shutdown.started" EventShutdownSucceeded EventType = "shutdown.succeeded" EventShutdownFailed EventType = "shutdown.failed" EventPatrolFailed EventType = "patrol.failed" )
type Locator ¶
type Locator struct {
SchemaVersion int `json:"schemaVersion"`
SessionID string `json:"sessionId"`
DiagnosticsDir string `json:"diagnosticsDir"`
StateLayout string `json:"stateLayout"`
StartedAt time.Time `json:"startedAt"`
}
func ReadLocator ¶
type ReadOptions ¶
type ReadResponse ¶
type ReadResponse struct {
SchemaVersion int `json:"schemaVersion"`
Availability Availability `json:"availability"`
ObservedAt time.Time `json:"observedAt"`
Freshness Freshness `json:"freshness"`
Status *Status `json:"status,omitempty"`
Events []Event `json:"events,omitempty"`
Cursor CursorInfo `json:"cursor"`
Error *DiagnosticError `json:"error,omitempty"`
}
func Read ¶
func Read(dir string, options ReadOptions) ReadResponse
func ReadFromLocator ¶
func ReadFromLocator(path string, options ReadOptions) ReadResponse
ReadFromLocator reads the active daemon store without making callers infer the service user's home directory or parse a systemd unit.
type ReaderIdentity ¶
type RuntimeLock ¶
type RuntimeLock struct {
// contains filtered or unexported fields
}
RuntimeLock prevents two singleton machine daemons from supervising the same host. Its lifetime is the daemon process lifetime.
func AcquireRuntimeLock ¶
func AcquireRuntimeLock(path string) (*RuntimeLock, error)
func (*RuntimeLock) Close ¶
func (l *RuntimeLock) Close() error
type Sanitizer ¶
type Sanitizer struct {
// contains filtered or unexported fields
}
func NewSanitizer ¶
type ShutdownCandidate ¶
type Status ¶
type Status struct {
SchemaVersion int `json:"schemaVersion"`
SessionID string `json:"sessionId"`
StartedAt time.Time `json:"startedAt"`
UpdatedAt time.Time `json:"updatedAt"`
State DaemonState `json:"state"`
Health DaemonHealth `json:"health"`
PatrolInterval string `json:"patrolInterval"`
LastPatrolAt *time.Time `json:"lastPatrolAt,omitempty"`
LastSuccessAt *time.Time `json:"lastSuccessfulPatrolAt,omitempty"`
LastError *DiagnosticError `json:"lastError,omitempty"`
WorkspaceCount int `json:"workspaceCount"`
Workspaces []WorkspaceStatus `json:"workspaces,omitempty"`
ShutdownCandidate *ShutdownCandidate `json:"shutdownCandidate,omitempty"`
LatestSequence uint64 `json:"latestSequence"`
}
type WorkspaceEvaluationState ¶
type WorkspaceEvaluationState string
const ( WorkspaceActive WorkspaceEvaluationState = "active" WorkspaceIdleDue WorkspaceEvaluationState = "idle_due" WorkspaceBusy WorkspaceEvaluationState = "busy" WorkspaceNotConfigured WorkspaceEvaluationState = "not_configured" WorkspaceInvalidConfig WorkspaceEvaluationState = "invalid_config" WorkspaceNotRunning WorkspaceEvaluationState = "not_running" )
type WorkspaceStatus ¶
type WorkspaceStatus struct {
ID string `json:"id"`
State WorkspaceEvaluationState `json:"state"`
LastActivityAt *time.Time `json:"lastActivityAt,omitempty"`
Timeout string `json:"inactivityTimeout,omitempty"`
IdleDeadlineAt *time.Time `json:"idleDeadlineAt,omitempty"`
Busy bool `json:"busy"`
ShutdownActionEnabled bool `json:"shutdownActionEnabled"`
BlocksMachineShutdown bool `json:"blocksMachineShutdown"`
BlockerReason string `json:"blockerReason,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.