Help us shape the future of Go! Take the 2026 Go Developer Survey

machine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package machine works out what host this process is running on: which distribution and release, and how much machine there is to use.

It is its own package because two callers need the same answer and neither should depend on the other: the agent reports these facts to the controller so a pool asking for Ubuntu 24.04 can be placed correctly, and the configuration loader uses them to give an unnamed host a name that says what it is instead of whatever the cloud provider called it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHostName

func DefaultHostName() string

DefaultHostName is the name an unnamed host is given: what it is, then which one it is, in the grammar of internal/naming -- "zoomies-16vcpu-32gb-ubuntu-2404-build01".

A machine that would say nothing about itself falls back to its bare hostname rather than to the bare prefix, because "zoomies" is not a name and the hostname at least distinguishes two hosts.

func Hostname

func Hostname() string

Hostname is this machine's short name, or "localhost" when the host will not say. It is the discriminator in a canonical host name.

Types

type Facts

type Facts struct {
	// OS is the kernel, as Go names it: linux, darwin, windows.
	OS string
	// Distro and OSVersion are the distribution and its release, e.g.
	// "ubuntu" and "24.04". Empty when the host cannot say, which is not an
	// error: an unstated platform simply constrains nothing.
	Distro    string
	OSVersion string
	Arch      string
	// CPUs and MemoryMB are what this agent may actually use, which is not
	// always what the machine has -- an agent in a container gets the cgroup's
	// share, and reporting the host's 64 cores from inside a two-core cgroup
	// would size every pool wrong.
	CPUs     int
	MemoryMB int64
}

Facts is what this host actually is: which distribution and release it runs, and how much of it there is.

The controller needs all of it. The distribution and release decide whether a pool asking for Ubuntu 24.04 may be placed here -- "linux" cannot pick a runner image -- and the size is what lets a host be named for what it is rather than for whatever the cloud provider called it.

func Detect

func Detect() Facts

Detect works out what this host is. Every probe is best-effort: a field it cannot establish is left empty rather than guessed, because a host that claims the wrong platform is worse than one that claims none.

func (Facts) Spec

func (m Facts) Spec(machine string) naming.Spec

Spec renders the machine in the naming grammar's terms, so that a host can be named for what it is.

type Usage

type Usage struct {
	CPUPercent        *float64
	MemoryAvailableMB *int64
}

Usage describes the whole machine, including work not owned by Zoomies. A missing value means unmeasured, never idle. Linux procfs is the only source for now; other platforms retain reservation-based placement.

type UsageSampler

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

UsageSampler takes CPU deltas between heartbeats without sleeping or asking Docker to do more work while it may already be overloaded.

func (*UsageSampler) Sample

func (s *UsageSampler) Sample(cpus int, memoryMB int64) Usage

Jump to

Keyboard shortcuts

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