machines

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package machines is Fort's static machine registry and deterministic placement (spec 022). It is pure core data — it imports neither ui nor any exec package — so placement, like routing, takes zero model calls (asserted by TestPlacementIsDeterministic). cmd/fort loads the registry and hands it to the engine as a Placer and to exec/cluster as the transport map.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save added in v0.6.0

func Save(path string, r *Registry) error

Save writes r as machines.yaml at path atomically: temp file in the same directory, then rename. machines.yaml holds no secrets, but CreateTemp yields 0600 and rename preserves it — harmless, and consistent with node.yaml.

Types

type Live added in v0.6.0

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

Live is a swappable registry shared by the placer, the cluster runtime's wiring, and the roster (spec 024): enrollment stores a new *Registry and every reader sees it immediately. The zero value holds no registry, which behaves exactly like single-machine mode.

func (*Live) Load added in v0.6.0

func (l *Live) Load() *Registry

Load returns the current registry, or nil when none is installed.

func (*Live) Place added in v0.6.0

func (l *Live) Place(agent, pin string) (string, error)

Place implements engine.Placer over the current registry. With no registry installed it preserves single-machine semantics: no placement, but an explicit pin is an error (there is nothing to pin to).

func (*Live) SetLocal added in v0.13.0

func (l *Live) SetLocal(name string)

SetLocal records the configured identity used by single-machine mode. It lets a client explicitly choose the same local machine advertised by the capability inventory without inventing a one-entry mesh registry.

func (*Live) Store added in v0.6.0

func (l *Live) Store(reg *Registry)

Store installs reg as the current registry.

type Machine

type Machine struct {
	Name   string   `yaml:"name" json:"name"`
	URL    string   `yaml:"url" json:"url"`
	Agents []string `yaml:"agents" json:"agents"`
}

Machine is one host in the registry: its stable name, the base URL of its Fort HTTP API, and the agents (providers) it can run.

type Registry

type Registry struct {
	Version  int       `yaml:"version" json:"version"`
	Machines []Machine `yaml:"machines" json:"machines"`
	// contains filtered or unexported fields
}

Registry is a parsed machines.yaml plus this machine's identity.

func Load

func Load(path, localName string) (*Registry, error)

Load reads and parses machines.yaml from path.

func Parse

func Parse(data []byte, localName string) (*Registry, error)

Parse parses machines.yaml and records localName as this machine's identity. localName is matched case-insensitively against the registry and canonicalized to the stored casing (so downstream name comparisons are exact).

func (*Registry) Local

func (r *Registry) Local() string

Local returns the canonical name of this machine.

func (*Registry) Machine

func (r *Registry) Machine(name string) (Machine, bool)

Machine returns the machine with the given name (case-insensitive).

func (*Registry) Names

func (r *Registry) Names() []string

Names returns machine names in registry order.

func (*Registry) Place

func (r *Registry) Place(agent, pin string) (string, error)

Place chooses, deterministically, the machine that will run agent:

  1. an explicit pin — must exist and offer the agent, else an error;
  2. otherwise the local machine, if it offers the agent;
  3. otherwise the first machine in registry order that offers the agent;
  4. otherwise an error.

It returns the canonical machine name. Place is a pure function of its inputs and the registry — no model calls (see TestPlacementIsDeterministic).

func (*Registry) WithMachine added in v0.6.0

func (r *Registry) WithMachine(m Machine) *Registry

WithMachine returns a copy of r with m added, or — when a machine of the same name (case-insensitive) exists — that entry's url and agents replaced. The stored (canonical) casing of an existing name wins. r is not mutated.

func (*Registry) Without added in v0.6.0

func (r *Registry) Without(name string) *Registry

Without returns a copy of r with the named machine (case-insensitive) removed. r is not mutated.

Jump to

Keyboard shortcuts

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