system

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 42 Imported by: 0

Documentation

Overview

Package system implements the daemon's system service: sync, install/upgrade, registration, and health. It owns the WebSocket connection to base, periodic pulls and state updates, and local task result handling with deduplication. Internal-only; external code should use pkg/core/system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WSConnected

func WSConnected() bool

func WSLastConnect

func WSLastConnect() (t time.Time)

func WSLastError

func WSLastError() *string

func WSReconnectsSinceStart

func WSReconnectsSinceStart() uint64

Types

type AccessTokenProvider

type AccessTokenProvider interface {
	GetAccessToken(ctx context.Context) (string, error)
}

AccessTokenProvider provides the current agent access token.

type AgentStatus

type AgentStatus struct {
	Mode    string `json:"mode"`
	UptimeS int64  `json:"uptime_s"`
}

type AgentUpdateV1

type AgentUpdateV1 struct {
	Schema       string       `json:"schema"`
	Seq          uint64       `json:"seq"`
	Epoch        string       `json:"epoch"`
	Full         bool         `json:"full"`
	InstanceID   string       `json:"instance_id"`
	AgentVersion string       `json:"agent_version"`
	Platform     PlatformInfo `json:"platform"`
	Status       *AgentStatus `json:"status,omitempty"`
}

type DefaultService

type DefaultService struct {
	// contains filtered or unexported fields
}

func NewDefaultService

func NewDefaultService(cfg *shared.Config, store store.InstanceStore, results store.TaskResultStore) *DefaultService

func (*DefaultService) GetInfo

func (s *DefaultService) GetInfo(ctx context.Context) (utils.SystemInfo, error)

func (*DefaultService) GetMode

func (s *DefaultService) GetMode(ctx context.Context) (system.ModeStatus, error)

GetMode returns the current daemon mode.

func (*DefaultService) GetTasks

func (s *DefaultService) GetTasks(ctx context.Context, status string) (system.TaskSummary, error)

func (*DefaultService) Install

func (s *DefaultService) Install(ctx context.Context, version string) (string, error)

func (*DefaultService) IsRegistered

func (s *DefaultService) IsRegistered(ctx context.Context) (system.RegistrationStatus, error)

func (*DefaultService) RegisterInstance

func (s *DefaultService) RegisterInstance(ctx context.Context, req system.RegisterInstanceRequest) error

func (*DefaultService) RequestDomain

func (s *DefaultService) RequestDomain(ctx context.Context, req system.RequestDomainRequest) (string, error)

During the installation process, this method is used to register the instance with the base, used for routing traffic to this instance instead of directly hitting it. This is to ensure HTTPS traffic is enforced on dployr instance. Please refer to the documentation at https://docs.dployr.dev/installation for more details.

func (*DefaultService) RunDoctor

func (s *DefaultService) RunDoctor(ctx context.Context) (string, error)

func (*DefaultService) SetMode

SetMode updates the daemon mode.

func (*DefaultService) SystemStatus

func (s *DefaultService) SystemStatus(ctx context.Context) (system.SystemStatus, error)

func (*DefaultService) UpdateBootstrapToken

func (s *DefaultService) UpdateBootstrapToken(ctx context.Context, req system.UpdateBootstrapTokenRequest) error

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor runs tasks by routing them through existing HTTP handlers.

func NewExecutor

func NewExecutor(logger *shared.Logger, handler http.Handler, tokens AccessTokenProvider) *Executor

NewExecutor creates a task executor that uses the web server's routes.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, task *tasks.Task) *tasks.Result

Execute runs a task by converting it to an HTTP request and routing it internally.

type HelloAckV1

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"`
}

type HelloV1

type HelloV1 struct {
	Schema           string       `json:"schema"`
	InstanceID       string       `json:"instance_id"`
	AgentVersion     string       `json:"agent_version"`
	Platform         PlatformInfo `json:"platform"`
	Capabilities     []string     `json:"capabilities,omitempty"`
	SchemasSupported []string     `json:"schemas_supported,omitempty"`
}

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(cfg *shared.Config, inst store.InstanceStore, results store.TaskResultStore) *Metrics

func (*Metrics) ServeHTTP

func (m *Metrics) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PlatformInfo

type PlatformInfo struct {
	OS   string `json:"os"`
	Arch string `json:"arch"`
	Go   string `json:"go"`
}

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

func NewSyncer

func NewSyncer(cfg *shared.Config, logger *shared.Logger, inst store.InstanceStore, results store.TaskResultStore, handler http.Handler) *Syncer

func (*Syncer) Start

func (s *Syncer) Start(ctx context.Context)

Jump to

Keyboard shortcuts

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