registry

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package registry is the shared list of running routers: $XDG_STATE_HOME/codex-router/registry (else ~/.local/state/...), one <endpoint_id>.json file per control endpoint. Every shell sees the same dir whatever its TMPDIR. An entry is only a hint: clients confirm it with a hello handshake, and readers prune entries whose endpoint is gone.

Index

Constants

View Source
const (
	KindSession = "session"
	KindBrain   = "brain"
)

Endpoint kinds: a stage 1 launcher session or a stage 2 per-home brain.

Variables

This section is empty.

Functions

func Alive

func Alive(ep Endpoint) bool

Alive reports whether ep's socket answers or its process still exists. The pid check keeps an endpoint that has registered but not yet listens. A reused pid keeps a dead entry until that process exits too; the hello handshake catches it meanwhile.

func List

func List(root string) ([]Endpoint, []Skipped, error)

List returns the entries in root ordered by start time. Files that are not regular, do not parse, or whose endpoint_id differs from the file name are returned as skipped instead of failing the whole list.

func Prune

func Prune(root string, ep Endpoint) error

Prune removes ep's entry, read earlier by List, when its endpoint is dead (Alive). An entry rewritten since (a restart reusing the id) stays: Prune re-reads it and removes it only if its pid and start time are unchanged. A write between that read and the remove can still lose; the entry then comes back with the endpoint's next registration.

func Remove

func Remove(root, id string) error

Remove deletes the entry for id. A missing entry is not an error: a reader may have pruned it first.

func Root

func Root(getenv func(string) string) (string, error)

Root returns the registry dir, $XDG_STATE_HOME/codex-router/registry, else ~/.local/state/codex-router/registry, creating it 0700. Relative values are ignored. Both the codex-router dir and the registry dir must be private to this user: whoever can write there can point clients at their own socket.

func Write

func Write(root string, ep Endpoint) error

Write stores ep as root/<ID>.json (0600) atomically, so readers see the old or the new entry, never a partial one. The temp file's leading dot keeps it out of List.

Types

type Endpoint

type Endpoint struct {
	ID       string    `json:"endpoint_id"`
	Kind     string    `json:"kind"`
	Protocol int       `json:"protocol"`
	PID      int       `json:"pid"`
	Started  time.Time `json:"started"`
	Home     home.Home `json:"home"`
	Socket   string    `json:"socket"`
}

Endpoint is one registry entry, stored as <ID>.json.

type Skipped

type Skipped struct {
	Path string
	Err  error
}

Skipped is a registry file List could not use.

Jump to

Keyboard shortcuts

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