usage

package
v0.31.5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: GPL-3.0 Imports: 6 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 usage measures the instance's disk footprint: how many bytes the artifacts, backend state, logs, mirror clones, staging area, and database occupy, totalled and broken down per repo. Sizes are computed by walking the data dir on every call — previews are local-first and the tree is modest, so live numbers beat a stale cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirSize

func DirSize(root string) int64

DirSize walks root summing regular-file sizes. Unreadable entries are skipped: usage reporting must never fail on a permission oddity.

func Reclaimable

func Reclaimable(dirs Dirs) int64

Reclaimable totals only the categories a retention sweep can shrink — the baseline for reporting how much a sweep gave back.

Types

type Dirs

type Dirs struct {
	Artifacts string
	State     string
	Logs      string
	Tmp       string
	DBPath    string
}

Dirs locates the trees a report covers. DBPath is the SQLite location actually opened (":memory:" for an ephemeral instance), not a default — reporting must size the real database, never a stale file from a previous on-disk run.

type DurableTier added in v0.11.0

type DurableTier interface {
	UsageBytes(ctx context.Context) (int64, error)
}

DurableTier optionally reports the byte footprint of the durable artifact tier (S3/MinIO). When a tier backs the instance, local artifact directories are a cache — evicted while their deploys stay live — so the on-disk number alone understates what is retained and can read as data loss. Implemented by *s3store.Tier; nil on a single-node instance with no tier.

type RepoUsage

type RepoUsage struct {
	Repo string `json:"repo"`
	// ArtifactsBytes covers published fe/be/dl artifacts *resident on local
	// disk* — with a durable tier configured this is a cache, not the
	// authoritative copy; StateBytes the mutable backend state dirs; LogsBytes
	// build and run logs; MirrorBytes the bare git clone.
	ArtifactsBytes int64 `json:"artifacts_bytes"`
	StateBytes     int64 `json:"state_bytes"`
	LogsBytes      int64 `json:"logs_bytes"`
	MirrorBytes    int64 `json:"mirror_bytes"`
	TotalBytes     int64 `json:"total_bytes"`
	// Deploys counts the repo's non-evicted deploys; EvictedDeploys the
	// evicted ones (rows kept as history, artifacts reclaimed).
	Deploys        int `json:"deploys"`
	EvictedDeploys int `json:"evicted_deploys"`
}

RepoUsage is one repo's slice of the report.

type Report

type Report struct {
	TotalBytes int64 `json:"total_bytes"`
	// ArtifactsBytes is the local-disk (resident) artifact footprint. With a
	// durable tier configured it is a cache of DurableBytes, not the whole
	// retained set — DurableTierConfigured says which regime is in effect so a
	// shrinking ArtifactsBytes reads as eviction-from-cache, not data loss.
	ArtifactsBytes int64 `json:"artifacts_bytes"`
	StateBytes     int64 `json:"state_bytes"`
	LogsBytes      int64 `json:"logs_bytes"`
	MirrorBytes    int64 `json:"mirror_bytes"`
	TmpBytes       int64 `json:"tmp_bytes"`
	DBBytes        int64 `json:"db_bytes"`
	// DurableTierConfigured reports whether a durable artifact tier backs local
	// disk. DurableBytes is the tier's total footprint, or 0 when no tier is
	// configured or its size could not be read (best-effort — never fails the
	// report). DurableBytes is not added into TotalBytes, which measures this
	// instance's local disk.
	DurableTierConfigured bool        `json:"durable_tier_configured"`
	DurableBytes          int64       `json:"durable_bytes"`
	Repos                 []RepoUsage `json:"repos"`
}

Report is the instance's disk usage, by category and by repo.

func Compute

func Compute(database *db.Store, dirs Dirs, durable DurableTier) (Report, error)

Compute walks dirs and totals the instance's usage. durable may be nil (no tier); when set, its total footprint is reported alongside the local one.

Jump to

Keyboard shortcuts

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