system

package
v0.4.1-beta.7 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package system defines the public contract for daemon-level operations in dployr.

It models system health, registration, installation/upgrade, domain requests, and mode management. Consumers should depend on the System interface defined here; the concrete implementation lives in internal/system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoctorResult

type DoctorResult struct {
	Status string `json:"status"`
	Output string `json:"output"`
	Error  string `json:"error,omitempty"`
}

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.

const (
	ModeReady    Mode = "ready"
	ModeUpdating Mode = "updating"
)

type ModeStatus

type ModeStatus struct {
	Mode Mode `json:"mode"`
}

ModeStatus describes the current daemon mode.

type RegisterInstanceRequest

type RegisterInstanceRequest struct {
	Claim      string `json:"claim"`
	InstanceID string `json:"instance_id"`
	Issuer     string `json:"issuer"`
	Audience   string `json:"audience"`
}

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

type SystemManager struct{}

func NewSystemManager

func NewSystemManager() *SystemManager

type SystemProxyStatus

type SystemProxyStatus struct {
	Status string `json:"status"`
	Routes int    `json:"routes"`
}

SystemProxyStatus describes proxy health and routing information.

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"`
	Uptime   string               `json:"uptime"`
	Services SystemServicesStatus `json:"services"`
	Proxy    SystemProxyStatus    `json:"proxy"`
}

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 UpdateBootstrapTokenRequest

type UpdateBootstrapTokenRequest struct {
	Token string `json:"token"`
}

UpdateBootstrapTokenRequest is used to bootstrap token

Jump to

Keyboard shortcuts

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