Documentation
¶
Overview ¶
Package helper is the node side of tops: it runs as root on a node, reads one request and writes one response.
Index ¶
Constants ¶
const ( ExitOK = 0 // the response says ok ExitNotOK = 1 // the response says why not ExitBadRequest = 2 // the request did not decode, or helper is not root )
Exit codes of tops node <op>
Variables ¶
var System = Host{Root: "/", Proc: "/proc", Cgroup: cgroupMount, Etc: "/etc", Affinity: pid1Affinity, Clock: clockSynced, Systemd: systemBus}
System is the machine the helper runs on.
Functions ¶
Types ¶
type Env ¶
type Env struct {
Host Host
Root bool // effective UID 0
Version string // tops' own version, reported by hello
Exe string // this binary, whose sha256 hello reports
Stdin io.Reader
Stdout io.Writer
Log *slog.Logger
}
Env is what Run needs from the process. cmd/tops passes the real ones; tests fake them.
type Host ¶
type Host struct {
Root string
Proc string
Cgroup string
Etc string
Affinity func() (int, error)
Clock func() (bool, error)
Systemd func(ctx context.Context) (Systemd, error)
}
Host is where the helper reads a machine: its root filesystem, /proc, the cgroup v2 mount, /etc, the number of CPUs PID 1 may run on, and whether the kernel clock is synchronised, and systemd.
func (Host) Cores ¶
Cores returns the effective cores: the CPUs PID 1 may run on, lowered by the cpuset.cpus.effective and the cpu.max quota of PID 1's cgroup or of any ancestor visible from here. A quota makes it fractional. "150000 100000" is 1.5.
func (Host) Facts ¶
Facts reads the files tops would write, the tops-owned directories, and the installed releases, and Temporal's systemd units.
func (Host) Hello ¶
Hello describes the machine: who it is, what it runs, and its effective size. version is the helper's own, the same as the workstation's tops.
type Systemd ¶
type Systemd interface {
ListUnitsByPatternsContext(ctx context.Context, states, patterns []string) ([]dbus.UnitStatus, error)
GetUnitPropertiesContext(ctx context.Context, unit string) (map[string]any, error)
GetUnitTypePropertiesContext(ctx context.Context, unit, unitType string) (map[string]any, error)
Close()
}
Systemd is the part of systemd's D-Bus API the helper reads. *dbus.Conn has it; tests fake it.