maintenance

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: LGPL-2.1 Imports: 18 Imported by: 0

README

mod/maintenance

mod/maintenance contains storage-only commands that run outside the serving runtime. The root main and runtime files keep thin wrappers for CLI wiring, signal handling, and user output; the command behavior lives here.

Place in the runtime

flowchart TB
    cli["mod/cli"] --> main["root wrappers"]
    main --> maintenance["mod/maintenance"]
    maintenance --> config["config validation"]
    maintenance --> storage["exclusive storage access"]
    maintenance --> output["text or JSON output"]

Responsibilities

  • Inspect durable storage and report versions, sizes, and orphan estimates.
  • Prune keys removed from release_mirrors.
  • Run SQLite vacuum and Pebble compaction.
  • Rebuild hot artifacts and digest helpers from durable storage.
  • Render maintenance errors in text or JSON without starting web, mesh, rescan, or telemetry runtime services.

Contracts

  • Maintenance commands require exclusive storage access.
  • Root wrappers may adapt CLI input, context cancellation, and process output, but they must not reimplement command logic.
  • JSON output must return structured English errors. Repair-prune failures use the same JSON error envelope as other maintenance failures.
  • Maintenance must treat hot files as regenerable and Pebble/SQLite as durable truth.

Important files

  • obj.go: command request, typed errors, and shared command constants.
  • run.go: command dispatcher and output mode handling.
  • selftest.go: artifact layout checks used before rebuild-sensitive operations.
  • rebuild.go: hot artifact and digest rebuild flow.
  • keysource.go: key source reconciliation.
  • render.go: text and JSON rendering helpers.

Operational notes

Stop the running server before inspect, prune, vacuum, or rebuild-cache. These commands intentionally avoid the normal runtime graph so they can fail early when storage is locked and so automation receives deterministic output.

Documentation

Index

Constants

View Source
const ArtifactLayoutGlobalKey = "artifact_layout"

Variables

This section is empty.

Functions

func ArtifactLayoutFingerprint

func ArtifactLayoutFingerprint() string

ArtifactLayoutFingerprint pins the revision of formats affecting cache artifacts.

func ListenersFromConfig

func ListenersFromConfig(configObj *stconf.ConfigObj, yggHost string) []overlay.ListenerCtxObj

ListenersFromConfig builds listener contexts for host-sensitive materializers.

func Run

func Run(ctx context.Context, configObj *stconf.ConfigObj, requestObj RequestObj, logArr ...zerolog.Logger) error

Run executes a maintenance command over exclusively opened storage.

Types

type ArtifactDriftObj

type ArtifactDriftObj struct {
	Key            string `json:"key"`
	Version        string `json:"version"`
	MaterializerID string `json:"materializer_id"`
	ArtifactKind   string `json:"artifact_kind"`
	ListenerID     string `json:"listener_id"`
	FormatVersion  uint32 `json:"format_version"`
	StoredHash     string `json:"stored_hash"`
	RebuiltHash    string `json:"rebuilt_hash"`
}

ArtifactDriftObj describes a drift of one materialized artifact.

func SelfTestFormats

func SelfTestFormats(ctx context.Context, storeObj *storage.Obj, overlayObj *overlay.Obj, listenerArr []overlay.ListenerCtxObj) ([]ArtifactDriftObj, error)

SelfTestFormats verifies small stored artifacts against current materializer descriptors.

type KeySourceVerdictObj

type KeySourceVerdictObj struct {
	Key    string
	Code   string
	Detail string
}

KeySourceVerdictObj explains a conflict between config release_mirrors and the persisted source binding.

func ReconcileKeySources

func ReconcileKeySources(ctx context.Context, storageObj *storage.Obj, configObj *stconf.ConfigObj) (map[string]struct{}, []string, []KeySourceVerdictObj, error)

ReconcileKeySources checks release_mirrors against already persisted first-source bindings.

type RebuildResultObj

type RebuildResultObj struct {
	Scanned uint64
	Drift   uint64
	Updated uint64
	Created uint64
	Pruned  uint64
	Items   []ArtifactDriftObj
}

RebuildResultObj aggregates the result of a full artifact verification.

func RebuildArtifacts

func RebuildArtifacts(ctx context.Context, storeObj *storage.Obj, overlayObj *overlay.Obj, listenerArr []overlay.ListenerCtxObj) (RebuildResultObj, error)

RebuildArtifacts rebuilds and verifies all materialized artifacts.

type ReportedErrObj

type ReportedErrObj struct {
	Err error
}

ReportedErrObj marks an error already rendered for the operator.

func (ReportedErrObj) Error

func (obj ReportedErrObj) Error() string

func (ReportedErrObj) Unwrap

func (obj ReportedErrObj) Unwrap() error

type RequestObj

type RequestObj struct {
	Inspect      bool
	Prune        bool
	Vacuum       bool
	RebuildCache bool
	Force        bool
	JsonOutput   bool
}

RequestObj describes one maintenance command without depending on the CLI layer.

func (RequestObj) CommandName

func (obj RequestObj) CommandName() string

CommandName returns the stable command name for output and the JSON envelope.

Jump to

Keyboard shortcuts

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