Documentation
¶
Overview ¶
Package system defines the public contract for daemon-level operations in dployr.
It models system health, registration, installation/upgrade, domain requests, mode management, and instance lifecycle sync with base over WebSockets. The concrete implementation lives in internal/system; consumers should depend on the System interface defined here.
Index ¶
- Constants
- type AuthDebug
- type CertDebug
- type DiskDebugEntry
- type DoctorResult
- type HelloAckV1
- type HelloV1
- type InstallRequest
- type Mode
- type ModeStatus
- type PlatformInfo
- type RegisterInstanceRequest
- type RegistrationStatus
- type RequestDomainRequest
- type RequestDomainResponse
- type ServiceHandler
- func (h *ServiceHandler) GetInfo(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) GetMode(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) Install(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) RegisterInstance(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) Registered(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) RequestDomain(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) RunDoctor(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) SetMode(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) SystemStatus(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) Tasks(w http.ResponseWriter, r *http.Request)
- func (h *ServiceHandler) UpdateBootstrapToken(w http.ResponseWriter, r *http.Request)
- type SetModeRequest
- type System
- type SystemDebug
- type SystemHealth
- type SystemManager
- type SystemProxyStatus
- type SystemResourcesDebug
- type SystemServicesStatus
- type SystemStatus
- type TaskSummary
- type TasksDebug
- type UpdateBootstrapTokenRequest
- type UpdateV1
- type WSDebug
Constants ¶
const ( HealthOK = "ok" HealthDegraded = "degraded" HealthDown = "down" )
Health status
const ( SystemStatusHealthy = "healthy" SystemStatusDegraded = "degraded" SystemStatusUnhealthy = "unhealthy" )
System status
const ( ProxyStatusRunning = "running" ProxyStatusStopped = "stopped" ProxyStatusUnknown = "unknown" )
Proxy status
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiskDebugEntry ¶ added in v0.4.3
type DiskDebugEntry struct {
Filesystem string `json:"filesystem"`
Mountpoint string `json:"mountpoint"`
SizeBytes int64 `json:"size_bytes,omitempty"`
UsedBytes int64 `json:"used_bytes,omitempty"`
AvailableBytes int64 `json:"available_bytes,omitempty"`
}
DiskDebugEntry represents disk usage for a single filesystem/mountpoint.
type DoctorResult ¶
type HelloAckV1 ¶ added in v0.4.2
type HelloAckV1 struct {
Schema string `json:"schema"`
Accept bool `json:"accept"`
Reason string `json:"reason,omitempty"`
FeaturesEnabled []string `json:"features_enabled,omitempty"`
ServerTime time.Time `json:"server_time"`
}
HelloAckV1 is sent by base to acknowledge the agent hello.
type HelloV1 ¶ added in v0.4.2
type HelloV1 struct {
Schema string `json:"schema"`
InstanceID string `json:"instance_id"`
BuildInfo version.BuildInfo `json:"build_info"`
Platform PlatformInfo `json:"platform"`
Capabilities []string `json:"capabilities,omitempty"`
SchemasSupported []string `json:"schemas_supported,omitempty"`
}
HelloV1 is sent by the agent when establishing a WebSocket connection.
type InstallRequest ¶
type InstallRequest struct {
Version string `json:"version"`
}
type Mode ¶
type Mode string
Mode represents the current mode. "ready" – normal operation, syncer active. "updating" – in the middle of an update/installation cycle.
type ModeStatus ¶
type ModeStatus struct {
Mode Mode `json:"mode"`
}
ModeStatus describes the current daemon mode.
type PlatformInfo ¶ added in v0.4.2
PlatformInfo describes the runtime platform of the agent.
type RegisterInstanceRequest ¶
type RegistrationStatus ¶
type RegistrationStatus struct {
Registered bool `json:"registered"`
}
RegistrationStatus reports whether the instance has been registered
type RequestDomainRequest ¶
type RequestDomainRequest struct {
Token string `json:"token"`
}
type RequestDomainResponse ¶
type RequestDomainResponse struct {
Domain string `json:"domain"`
}
type ServiceHandler ¶
type ServiceHandler struct {
Svc System
}
func NewServiceHandler ¶
func NewServiceHandler(s System) *ServiceHandler
func (*ServiceHandler) GetInfo ¶
func (h *ServiceHandler) GetInfo(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) GetMode ¶
func (h *ServiceHandler) GetMode(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) Install ¶
func (h *ServiceHandler) Install(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) RegisterInstance ¶
func (h *ServiceHandler) RegisterInstance(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) Registered ¶
func (h *ServiceHandler) Registered(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) RequestDomain ¶
func (h *ServiceHandler) RequestDomain(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) RunDoctor ¶
func (h *ServiceHandler) RunDoctor(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) SetMode ¶
func (h *ServiceHandler) SetMode(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) SystemStatus ¶
func (h *ServiceHandler) SystemStatus(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) Tasks ¶
func (h *ServiceHandler) Tasks(w http.ResponseWriter, r *http.Request)
func (*ServiceHandler) UpdateBootstrapToken ¶
func (h *ServiceHandler) UpdateBootstrapToken(w http.ResponseWriter, r *http.Request)
type SetModeRequest ¶
type SetModeRequest struct {
Mode Mode `json:"mode"`
}
SetModeRequest is used by the agent to change the daemon mode.
type System ¶
type System interface {
// GetInfo returns system information.
GetInfo(ctx context.Context) (utils.SystemInfo, error)
// RunDoctor runs the system doctor script and returns its combined output.
RunDoctor(ctx context.Context) (string, error)
// Install installs dployr; if version is empty, the latest version is installed.
Install(ctx context.Context, version string) (string, error)
// SystemStatus returns high-level health information.
SystemStatus(ctx context.Context) (SystemStatus, error)
// RequestDomain requests and assigns a new random domain from base to the system.
RequestDomain(ctx context.Context, req RequestDomainRequest) (string, error)
// RegisterInstance registers the system with the base and assigns an instance id
RegisterInstance(ctx context.Context, req RegisterInstanceRequest) error
// GetTasks returns a summary of tasks for the given status (e.g. "pending", "completed").
GetTasks(ctx context.Context, status string) (TaskSummary, error)
// GetMode returns the current daemon mode.
GetMode(ctx context.Context) (ModeStatus, error)
// SetMode updates the daemon mode.
SetMode(ctx context.Context, req SetModeRequest) (ModeStatus, error)
// UpdateBootstrapToken updates the bootstrap token.
UpdateBootstrapToken(ctx context.Context, req UpdateBootstrapTokenRequest) error
// IsRegistered returns true if this daemon has been registered with base.
IsRegistered(ctx context.Context) (RegistrationStatus, error)
}
System defines an interface for system operations.
type SystemDebug ¶
type SystemDebug struct {
WS WSDebug `json:"ws"`
Tasks TasksDebug `json:"tasks"`
Auth *AuthDebug `json:"auth,omitempty"`
Cert *CertDebug `json:"cert,omitempty"`
System *SystemResourcesDebug `json:"system,omitempty"`
}
type SystemHealth ¶
type SystemManager ¶
type SystemManager struct{}
func NewSystemManager ¶
func NewSystemManager() *SystemManager
type SystemProxyStatus ¶
SystemProxyStatus describes proxy health and routing information.
type SystemResourcesDebug ¶ added in v0.4.3
type SystemResourcesDebug struct {
CPUCount int `json:"cpu_count"`
MemTotalBytes int64 `json:"mem_total_bytes,omitempty"`
MemUsedBytes int64 `json:"mem_used_bytes,omitempty"`
MemFreeBytes int64 `json:"mem_free_bytes,omitempty"`
SwapTotalBytes int64 `json:"swap_total_bytes,omitempty"`
SwapUsedBytes int64 `json:"swap_used_bytes,omitempty"`
Disks []DiskDebugEntry `json:"disks,omitempty"`
}
SystemResourcesDebug provides high-level system resource information for debugging.
type SystemServicesStatus ¶
type SystemServicesStatus struct {
Total int `json:"total"`
Running int `json:"running"`
Stopped int `json:"stopped"`
}
SystemServicesStatus describes aggregate service state.
type SystemStatus ¶
type SystemStatus struct {
Status string `json:"status"`
Mode Mode `json:"mode"`
Uptime string `json:"uptime"`
Services SystemServicesStatus `json:"services"`
Proxy SystemProxyStatus `json:"proxy"`
Health SystemHealth `json:"health"`
Debug *SystemDebug `json:"debug,omitempty"`
}
SystemStatus describes high-level health information about the daemon.
type TaskSummary ¶
type TaskSummary struct {
Count int `json:"count"`
}
TaskSummary represents a simple count of tasks for a given status.
type TasksDebug ¶
type TasksDebug struct {
Inflight int `json:"inflight"`
DoneUnsent int `json:"done_unsent"`
LastTaskID string `json:"last_task_id,omitempty"`
LastTaskStatus string `json:"last_task_status,omitempty"`
LastTaskDurMs int64 `json:"last_task_dur_ms,omitempty"`
LastTaskAtRFC3339 string `json:"last_task_at,omitempty"`
}
type UpdateBootstrapTokenRequest ¶
type UpdateBootstrapTokenRequest struct {
Token string `json:"token"`
}
UpdateBootstrapTokenRequest is used to bootstrap token
type UpdateV1 ¶ added in v0.4.3
type UpdateV1 struct {
Schema string `json:"schema"`
Seq uint64 `json:"seq"`
Epoch string `json:"epoch"`
Full bool `json:"full"`
InstanceID string `json:"instance_id"`
BuildInfo version.BuildInfo `json:"build_info"`
Platform PlatformInfo `json:"platform"`
Status *SystemStatus `json:"status,omitempty"`
}
UpdateV1 represents the status update payload sent from the agent to base. This struct defines the core schema relied upon by clients interacting with the dployr API.