registry

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Name          string            `json:"name"`
	Address       string            `json:"address"`
	Role          string            `json:"role,omitempty"`
	Labels        map[string]string `json:"labels,omitempty"`
	OS            string            `json:"os,omitempty"`
	Arch          string            `json:"arch,omitempty"`
	CPUCount      int               `json:"cpu_count,omitempty"`
	Memory        int64             `json:"memory_bytes,omitempty"`
	LastSeen      time.Time         `json:"last_seen,omitempty"`
	TransportMode string            `json:"transport_mode,omitempty"`
	TLSServerName string            `json:"tls_server_name,omitempty"`
}

Node represents a registered test machine.

type NodeContext

type NodeContext struct {
	WorkingDir string            `json:"working_dir,omitempty"`
	Env        map[string]string `json:"env,omitempty"`
}

NodeContext stores persistent per-node defaults.

type Registry

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

Registry manages nodes, topologies, and contexts with JSON persistence.

Multiple LabLinkServer processes may share the same nodes.json (one per AI client session). To prevent silent last-writer-wins clobber, every read-modify-write cycle is serialised through an OS-level advisory lock on a sidecar "<filePath>.lock" file, and in-memory state is reloaded from disk whenever the on-disk mtime has moved ahead of what we last loaded.

func Load

func Load(filePath string) *Registry

Load reads the registry from a JSON file, or creates an empty one.

func (*Registry) AllNodes

func (r *Registry) AllNodes() []*Node

AllNodes returns a copy of all nodes.

func (*Registry) AllTopologyNames

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

AllTopologyNames returns the names of all topologies.

func (*Registry) GetNode

func (r *Registry) GetNode(name string) (*Node, bool)

GetNode returns a node by name.

func (*Registry) GetNodeContext

func (r *Registry) GetNodeContext(name string) (*NodeContext, bool)

GetNodeContext returns the persistent context for a node.

func (*Registry) GetTopology

func (r *Registry) GetTopology(name string) (*Topology, bool)

GetTopology returns a topology by name.

func (*Registry) NodesByRole

func (r *Registry) NodesByRole(role string) []*Node

NodesByRole returns all nodes with the given role. Comparison is case-insensitive.

func (*Registry) NodesForTopologyRole

func (r *Registry) NodesForTopologyRole(topologyName, role string) []*Node

NodesForTopologyRole returns nodes for a specific role in a topology. Role comparison is case-insensitive.

func (*Registry) RemoveNode

func (r *Registry) RemoveNode(name string) error

RemoveNode deletes a node by name.

func (*Registry) RenameNode

func (r *Registry) RenameNode(oldName, newName string) error

RenameNode renames a node, updating all references in contexts and topologies.

func (*Registry) Save

func (r *Registry) Save() error

Save persists the registry to disk. Equivalent to a no-op write under the cross-process lock, useful when the caller has mutated state through a path that didn't already save.

func (*Registry) SetNode

func (r *Registry) SetNode(n *Node) error

SetNode adds or updates a node.

func (*Registry) SetNodeContext

func (r *Registry) SetNodeContext(name string, ctx *NodeContext) error

SetNodeContext sets persistent defaults for a node.

func (*Registry) SetTopology

func (r *Registry) SetTopology(t *Topology) error

SetTopology adds or updates a topology.

type Topology

type Topology struct {
	Name  string              `json:"name"`
	Roles map[string][]string `json:"roles"` // role -> list of node names
}

Topology is a named group of nodes with role assignments.

Jump to

Keyboard shortcuts

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