runregistry

package
v1.59.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package runregistry persists discovery records for running docker-agent processes that expose a control plane (see run --listen). Records live as per-pid JSON files under <data dir>/runs so external tools can enumerate live runs and connect to them.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRun = errors.New("no live docker-agent run found; start one with: docker-agent run --listen 127.0.0.1:0")

ErrNoRun is returned when no live run can be found that satisfies the caller's request (empty registry, or no record matches the target).

Functions

func Dir

func Dir() string

Dir is the directory holding run records.

func Write

func Write(rec Record) (func(), error)

Write atomically persists a record for the current process and returns a cleanup func that removes it. Cleanup is safe to call more than once.

The registry directory is created with 0o700 so other local users cannot enumerate live PIDs/addresses by listing it. Individual records are still written with 0o600 for the same reason. Writes go through a sibling temp file + rename so concurrent readers never see torn JSON.

Types

type Record

type Record struct {
	PID       int       `json:"pid"`
	Addr      string    `json:"addr"`
	SessionID string    `json:"session_id"`
	Agent     string    `json:"agent,omitempty"`
	StartedAt time.Time `json:"started_at"`
}

Record describes a running docker-agent that exposes a control plane.

func Find

func Find(target string) (Record, error)

Find resolves a target reference to a single live record.

An empty target returns the most recently started run. A numeric target is matched by PID; a target starting with "http://" or "https://" is matched against record addresses; anything else is matched as a (possibly partial) session ID. PID and address matches are exact. Session-ID matching prefers exact equality and only falls back to substring matching when no record matches exactly; ambiguous substring matches return an error so callers don't act on the wrong session.

func Latest

func Latest() (Record, bool, error)

Latest returns the most recently started live record, or false when none.

func List

func List() ([]Record, error)

List returns every record currently registered. Stale records (whose pid is no longer alive) are skipped and best-effort removed.

Jump to

Keyboard shortcuts

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