Documentation
¶
Overview ¶
Package proto holds the service messages exchanged with the panel. It mirrors the panel's internal/agentlink/protocol.go; keep both in sync with docs/protokol-agent.md.
Index ¶
- Constants
- type AllocationSpec
- type CertRenew
- type CertRenewed
- type ConfigFileSpec
- type ConsoleCommand
- type ConsoleLines
- type FileChunk
- type FileDelete
- type FileEntry
- type FileList
- type FilePath
- type FileRead
- type FileRename
- type FileWrite
- type InstallSpec
- type Limits
- type PowerRequest
- type SFTPAuth
- type SFTPLogin
- type ServiceRef
- type ServiceSpec
- type ServiceState
- type Stats
- type StopSpec
Constants ¶
const ( TypeOK = "ok" TypeError = "error" TypeServiceCreate = "service.create" TypeServiceReinstall = "service.reinstall" TypeServiceDelete = "service.delete" TypeServicePower = "service.power" TypeServiceState = "service.state" )
Message types.
const ( StateInstalling = "installing" StateInstallFailed = "install_failed" StateOffline = "offline" StateStarting = "starting" StateRunning = "running" StateStopping = "stopping" StateCrashed = "crashed" )
Service states.
const ( TypeConsoleBacklog = "console.backlog" // panel -> agent: ServiceRef; reply ConsoleLines (recent output) TypeConsoleSubscribe = "console.subscribe" // panel -> agent: ServiceRef; start streaming lines and stats TypeConsoleUnsubscribe = "console.unsubscribe" // panel -> agent: ServiceRef TypeConsoleCommand = "console.command" // panel -> agent: ConsoleCommand; written to stdin TypeConsoleLine = "console.line" // agent -> panel event: ConsoleLines TypeStats = "stats" // agent -> panel event: Stats )
Console and statistics message types.
const ( TypeFilesList = "files.list" // FilePath -> FileList TypeFilesRead = "files.read" // FileRead -> FileChunk TypeFilesWrite = "files.write" // FileWrite TypeFilesMkdir = "files.mkdir" // FilePath TypeFilesRename = "files.rename" // FileRename TypeFilesDelete = "files.delete" // FileDelete )
File operations (panel -> agent). Paths are relative to the service's data directory (/home/container in the container); ".." and symlinks never lead outside it.
const ChunkSize = 512 << 10
ChunkSize is the largest piece of file data in one message (base64 keeps frames under 1 MiB).
const TypeCertRenew = "cert.renew"
TypeCertRenew is an agent -> panel request: CertRenew, answered with CertRenewed.
const TypeSFTPAuth = "sftp.auth"
TypeSFTPAuth is an agent -> panel request: SFTPAuth, answered with SFTPLogin.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllocationSpec ¶
AllocationSpec is the service's IP:port.
type CertRenew ¶
type CertRenew struct {
CSR string `json:"csr"`
}
CertRenew carries a certificate request for a fresh node key.
type CertRenewed ¶
type CertRenewed struct {
Certificate string `json:"certificate"`
}
CertRenewed is the new client certificate (PEM).
type ConfigFileSpec ¶
type ConfigFileSpec struct {
Path string `json:"path"`
Parser string `json:"parser"`
Find json.RawMessage `json:"find"`
}
ConfigFileSpec is an egg config file rewrite.
type ConsoleCommand ¶
ConsoleCommand is a line typed into the server console.
type ConsoleLines ¶
ConsoleLines carries console output (newest last).
type FileChunk ¶
type FileChunk struct {
Size int64 `json:"size"` // total file size
Data []byte `json:"data"`
EOF bool `json:"eof"`
}
FileChunk is file data; Data is base64 (encoding/json does that for []byte).
type FileDelete ¶
FileDelete removes files and directories (recursively).
type FileEntry ¶
type FileEntry struct {
Name string `json:"name"`
Size int64 `json:"size"`
Mode string `json:"mode"`
ModTime int64 `json:"mod_time"` // unix seconds
IsDir bool `json:"is_dir"`
Symlink bool `json:"symlink"`
}
FileEntry is one directory entry.
type FileRead ¶
type FileRead struct {
ID string `json:"id"`
Path string `json:"path"`
Offset int64 `json:"offset"`
Length int `json:"length"`
}
FileRead asks for up to Length bytes (<= ChunkSize) at Offset.
type FileRename ¶
type FileRename struct {
ID string `json:"id"`
From string `json:"from"`
To string `json:"to"`
Overwrite bool `json:"overwrite,omitempty"`
}
FileRename moves From to To. Overwrite replaces an existing regular file at To (used to finish uploads and saves atomically); directories are never replaced.
type FileWrite ¶
type FileWrite struct {
ID string `json:"id"`
Path string `json:"path"`
Content string `json:"content,omitempty"`
Data []byte `json:"data,omitempty"`
Append bool `json:"append,omitempty"`
}
FileWrite writes Content (text) or Data (bytes); Append adds to the end instead of replacing.
type InstallSpec ¶
type InstallSpec struct {
Container string `json:"container"`
Entrypoint string `json:"entrypoint"`
Script string `json:"script"`
}
InstallSpec is the egg's install script and its container.
type Limits ¶
type Limits struct {
MemoryMB int `json:"memory_mb"`
CPUPercent int `json:"cpu_percent"`
DiskMB int `json:"disk_mb"`
PIDs int `json:"pids"`
}
Limits are container resource limits.
type PowerRequest ¶
PowerRequest is start, stop, restart or kill.
type SFTPAuth ¶
type SFTPAuth struct {
Username string `json:"username"`
Password string `json:"password"`
IP string `json:"ip"`
}
SFTPAuth asks the panel whether a username/password may open a service over SFTP.
type SFTPLogin ¶
type SFTPLogin struct {
ServiceID string `json:"service_id"`
}
SFTPLogin names the service the user may access.
type ServiceSpec ¶
type ServiceSpec struct {
ID string `json:"id"`
Image string `json:"image"`
Invocation string `json:"invocation"`
Env map[string]string `json:"env"`
Install InstallSpec `json:"install"`
Stop StopSpec `json:"stop"`
DoneMarkers []string `json:"done_markers"`
ConfigFiles []ConfigFileSpec `json:"config_files"`
Limits Limits `json:"limits"`
Allocation AllocationSpec `json:"allocation"`
}
ServiceSpec is everything needed to install and run one service.
type ServiceState ¶
type ServiceState struct {
ID string `json:"id"`
State string `json:"state"`
Detail string `json:"detail,omitempty"`
}
ServiceState reports a service's state.
type Stats ¶
type Stats struct {
ID string `json:"id"`
CPUPercent float64 `json:"cpu_percent"` // 100 = one core
MemoryBytes uint64 `json:"memory_bytes"`
MemoryLimitBytes uint64 `json:"memory_limit_bytes"`
NetRxBytes uint64 `json:"net_rx_bytes"`
NetTxBytes uint64 `json:"net_tx_bytes"`
DiskBytes uint64 `json:"disk_bytes"`
}
Stats is a resource sample of a running service.