status

package
v0.24.0-rc.1 Latest Latest
Warning

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

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

Documentation

Overview

Package status is the commands that report on anfra itself: version, and status of the warm server and its sidecars.

Index

Constants

View Source
const SkillsUnknown = "unknown"

SkillsUnknown is the skills arg when the version of the skills in use isn't known: a skill with no stamp, as copies from before the stamp have none.

Variables

View Source
var Status = command.Define(command.Def[command.NoInput, StatusResult]{
	Name:  "status",
	Short: "Report the repo, and whether anfra serve is running and its sidecars are healthy",
	Long: "Report the repo, and whether `anfra serve` is running and its sidecars are healthy.\n\n" +
		"For this anfra's own version, and whether it is behind, see `anfra version`.",
	ReadOnly: true,

	Run: func(ctx context.Context, cc command.CommandContext, _ command.NoInput) (StatusResult, error) {
		r := StatusResult{Repo: repoStatus(cc.Repo), Server: checkStatus(ctx, cc.Clients)}
		if s := cc.Server; s != nil {
			r.Server.URL, r.Server.InstanceID, r.Server.Version = s.URL, s.InstanceID, s.Version
		}
		if r.Server.State == StateDegraded && r.Repo.Logs != "" {
			r.Hints = append(r.Hints, "Run `anfra logs` to see why "+r.Server.Sidecars.failing()+" answering.")
		}
		r.Cache, r.Hints = cacheStatus(ctx, cc.QueryCache, r.Hints)
		return r, nil
	},
	Valid: func(r StatusResult) bool { return r.Server.State == StateHealthy },
})

Status reports the repo, and whether a warm server is running and its sidecars are healthy.

View Source
var Version = command.Define(command.Def[VersionInput, VersionResult]{
	Name:  "version",
	Short: "Print the anfra version, and say when anfra or the anfra skills are behind",
	Long: "Print the anfra version, and say when anfra or the anfra skills are behind.\n\n" +
		"For this repo's server, and whether it is running, see `anfra status`.",
	ReadOnly: true,
	Check:    checkVersion,

	Run: func(_ context.Context, cc command.CommandContext, in VersionInput) (VersionResult, error) {
		return runVersion(cc, in, time.Now()), nil
	},
})

Version prints the anfra version and, given the version of the anfra skills in use, compares both with the latest the host knows of, saying what to act on as hints (docs/designs/agent-setup.md). It reads only what the host cached: no network, no files.

Functions

This section is empty.

Types

type CacheStatus added in v0.21.0

type CacheStatus struct {
	Query querycache.Summary `json:"query" doc:"the query cache, which keeps queries' results"`
}

CacheStatus is the repo's caches.

type RepoStatus added in v0.17.0

type RepoStatus struct {
	ID string `json:"id" doc:"the repo's id, which names its state folder: <ANFRA_HOME>/repos/<id>"`
	// Logs is the repo's log file; absent for a repo with no directory (a
	// managed repo), whose host keeps its logs.
	Logs string `` /* 147-byte string literal not displayed */
}

RepoStatus is the repo the command runs on.

type ServerStatus added in v0.17.0

type ServerStatus struct {
	State      State          `json:"state" enum:"healthy,degraded,not_running"`
	URL        string         `json:"url,omitempty"`
	InstanceID string         `json:"instance_id,omitempty"`
	Version    string         `json:"version,omitempty"`
	Sidecars   *SidecarHealth `json:"sidecars,omitempty"`
}

ServerStatus is the warm server's state and, when it is running, where it is, its version and its sidecars' health.

type SidecarHealth

type SidecarHealth struct {
	Node       string `json:"node"`
	CanalQuery string `json:"canal-query"`
}

SidecarHealth is each sidecar's health: "ok" or the error message.

type SkillsResult added in v0.15.0

type SkillsResult struct {
	// Version is the skills version given; absent for unknown.
	Version string `json:"version,omitempty"`
	// Latest is the newest skills version known, never older than Version: they
	// differ only when Version is behind. Absent when none is known yet.
	Latest string `json:"latest,omitempty"`
	// Checked is the date of the host's last check, when it is more than two
	// days old.
	Checked string `json:"checked,omitempty"`
}

SkillsResult is the anfra skills in use against the latest known.

type State

type State string

State is the warm server's state.

const (
	// StateHealthy: the server is running, and every sidecar answers.
	StateHealthy State = "healthy"
	// StateDegraded: the server is running, and a sidecar does not answer.
	StateDegraded State = "degraded"
	// StateNotRunning: no warm server.
	StateNotRunning State = "not_running"
)

type StatusResult

type StatusResult struct {
	Repo   RepoStatus   `json:"repo"`
	Server ServerStatus `json:"server"`
	// Cache is the repo's caches; absent when the host keeps none.
	Cache *CacheStatus `json:"cache,omitempty" doc:"the repo's caches, read without changing them. Absent when the server keeps none."`
	// Hints are left to the host: the CLI adds its own, such as where to see
	// the repo's publishing.
	Hints []string `json:"hints,omitempty" doc:"what to do next, if any"`
}

StatusResult is the `status` result: the repo, and its warm server.

type VersionInput added in v0.15.0

type VersionInput struct {
	Skills string `` /* 231-byte string literal not displayed */
}

VersionInput is the version of the anfra skills in use, to compare.

func (VersionInput) TransformSchema added in v0.15.0

func (VersionInput) TransformSchema(_ huma.Registry, s *huma.Schema) *huma.Schema

type VersionResult

type VersionResult struct {
	Version string `json:"version"`
	// Update is the newest release the host knows of; absent when it does not
	// check for updates or has not checked yet.
	Update *command.UpdateInfo `json:"update,omitempty"`
	// Skills compares the skills version given with the latest; absent when
	// none was given.
	Skills *SkillsResult `json:"skills,omitempty"`
	// Hints are what to act on, for an agent to follow; absent when nothing is.
	Hints []string `json:"hints,omitempty"`
}

VersionResult is the `version` result. The CLI prints its keys in alphabetical order, so skills' latest: comes before update's: the skills' session hook, which reads the first latest: line as anfra's, gets skills only when it passes --skills.

Jump to

Keyboard shortcuts

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