registry

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package registry manages a shared file-based registry of running xpo board instances so peers can discover each other.

All instances are peers — there is no master. Each instance writes its {name, port, pid, root_dir, started_at} entry on startup and removes it on clean shutdown. Stale entries (process no longer alive) are pruned whenever the registry is read.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFreePort

func FindFreePort(startPort, maxAttempts int) (net.Listener, int, error)

FindFreePort tries to bind a TCP listener starting at startPort, incrementing up to maxAttempts-1 times. Returns the listener and the port actually bound.

func Register

func Register(name string, port int, rootDir string) error

Register adds the current process to the registry. Stale entries and any existing entry for this PID are removed first.

func UnregisterByPID

func UnregisterByPID(pid int) error

UnregisterByPID removes the entry for the given PID, if any.

Types

type Entry

type Entry struct {
	Name      string    `json:"name"`
	Port      int       `json:"port"`
	PID       int       `json:"pid"`
	RootDir   string    `json:"root_dir"`
	StartedAt time.Time `json:"started_at"`
}

Entry represents a running xpo board instance.

func List

func List() ([]Entry, error)

List returns all live registered instances, pruning any stale entries from the file as a side effect.

Jump to

Keyboard shortcuts

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