Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("registry: entry not found")
ErrNotFound is returned by Read when no entry exists for the given cwd.
var HealthTimeout = 500 * time.Millisecond
Functions ¶
func IsAlive ¶
IsAlive returns true if BOTH (a) the recorded HubPID is alive on this host AND (b) GET <HubURL> succeeds at the TCP/HTTP level within HealthTimeout. Both checks are required because a recycled PID can pass (a) but fail (b).
The HTTP probe doesn't require any specific endpoint — any HTTP response (including 4xx) means the port is bound and serving, which is what we actually want to know. The Fossil HTTP server bones uses doesn't expose a /health endpoint and we deliberately don't add a sidecar HTTP server just for the probe.
func IsOrphan ¶ added in v0.7.0
IsOrphan reports whether e represents a process that is alive on this host but whose workspace is no longer reachable. Three signals qualify a workspace as gone:
- e.Cwd does not exist on disk (ENOENT)
- e.Cwd exists but its workspace marker (.bones/agent.id) does not
- e.Cwd resolves into the user's Trash (~/.Trash on macOS, the XDG-Trash equivalent on Linux)
The PID-alive check is the same one IsAlive uses; an entry whose PID is dead is not an orphan (it's a stale entry awaiting prune) and will be reported by IsAlive returning false.
func Reap ¶ added in v0.7.0
Reap terminates the process for e and removes its registry entry. SIGTERM first; if the PID is still alive after reapGrace, SIGKILL. Returns nil on success (process gone, entry removed) or an error describing which step failed. The entry is removed even after SIGKILL — leaving it would create a permanent registry record for a process that, by definition, isn't going to come back.
func RegistryDir ¶
func RegistryDir() string
RegistryDir returns the directory that holds workspace entry files.
func WorkspaceID ¶
WorkspaceID returns a deterministic 16-hex-char identifier for an absolute cwd. Used as the registry filename: ~/.bones/workspaces/<id>.json
Types ¶
type Entry ¶
type Entry struct {
Cwd string `json:"cwd"`
Name string `json:"name"`
HubURL string `json:"hub_url"`
NATSURL string `json:"nats_url"`
HubPID int `json:"hub_pid"`
StartedAt time.Time `json:"started_at"`
}
Entry is one workspace's registry record. One JSON file per Entry at ~/.bones/workspaces/<WorkspaceID>.json.
type HubStatus ¶ added in v0.8.0
type HubStatus string
HubStatus is a coarse liveness label produced by ListInfo. Values:
HubRunning — registry recorded a hub PID, the PID is alive on this host,
and a quick TCP/HTTP probe of HubURL returned a response.
HubStopped — registry has an entry, but the hub is not reachable
(PID dead OR HTTP probe failed).
HubUnknown — the entry has no enough info to probe (e.g. missing
HubURL/HubPID), or a probe was deliberately skipped.
type Info ¶ added in v0.8.0
type Info struct {
Entry
ID string `json:"id"`
AgentID string `json:"agent_id"`
HubStatus HubStatus `json:"hub_status"`
LastTouched time.Time `json:"last_touched"`
}
Info is one workspace registry record enriched with the on-disk filename (ID), file mtime (LastTouched), the workspace's agent.id marker (when present), and a coarse hub liveness label.
ID is the hex string used as the registry filename: ~/.bones/workspaces/<ID>.json. It equals WorkspaceID(Cwd).
func ListInfo ¶ added in v0.8.0
ListInfo enumerates every registry entry, attaching ID + mtime + agent.id + hub-status. Corrupt or unreadable files are skipped (matching List). The hub-status probe runs IsAlive on each entry; callers that want to skip the probe (e.g. for fast paths) should use List + their own enrichment.
Results are sorted by Name, then Cwd, for stable output across calls.