index

package
v1.66.1 Latest Latest
Warning

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

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

Documentation

Overview

Package index holds what a store index reports about its sets and the store policy, as the admin surface shows them.

Index

Constants

View Source
const (
	// SetActive accepts commits.
	SetActive = "active"
	// SetClosing was deleted and keeps its commits through the trash window.
	SetClosing = "closing"
	// SetDeleted has no live commits left.
	SetDeleted = "deleted"
)

Set states.

View Source
const PlaceholderSet = "legacy"

PlaceholderSet names the set commits that name no set are indexed under; when a set of that name exists, the first free of PlaceholderSet-2, PlaceholderSet-3, … is used instead.

Variables

View Source
var ErrIndexed = errors.New("commit is already indexed")

ErrIndexed refuses to index a commit the index already has a row for.

Functions

func ReadRefs

func ReadRefs(r io.Reader) ([]*proto.Ref, error)

ReadRefs reads refs printed as hex, one per line, skipping blank lines.

Types

type CommitDetail

type CommitDetail struct {
	Commit *proto.Commit
	// Ref is the commit object's own ref, which names it to a caller that
	// wants to pin or read it.
	Ref *proto.Ref
	// LogicalSize is what the set's files held at this commit, and Files
	// how many there were; nil when nothing measured it, which is every
	// commit written before the index started recording it.
	LogicalSize, Files *int64
	// RetainedBy names the retention rules keeping this commit, comma
	// separated: "last", "within", "pinned", "hourly", "daily", "weekly",
	// "monthly". It is empty for a commit retention has not evaluated yet
	// or has retired.
	RetainedBy string
	// Incomplete reports a commit indexed around objects the store no
	// longer holds, which cannot be restored whole.
	Incomplete bool
}

CommitDetail is a commit together with what the index knows about it beyond the stored object: how big the set was when it was taken, and which retention rule is keeping it.

type CommitIndexer

type CommitIndexer interface {
	IndexCommits(ctx context.Context, refs []*proto.Ref, dryRun bool) ([]IndexedSet, error)
}

CommitIndexer is an index that indexes commits the store holds.

type IndexedSet

type IndexedSet struct {
	// SetID is 0 for a set a dry run would create under a fresh id.
	SetID int64
	Set   string
	// Created is a set that did not exist before.
	Created bool
	// Placeholder is a set the commits went to because they name none.
	Placeholder bool
	Commits     int
	// Chained is whether each commit names the one received before it as
	// its parent.
	Chained bool
	// Oldest and Newest are the receipt times of the first and last commit.
	Oldest, Newest time.Time
	// Indexed counts the commits indexed, Tied those of them indexed a
	// microsecond after their set's newest, and Behind those received
	// before the set's newest and left out; all 0 on a dry run.
	Indexed, Tied, Behind int
}

IndexedSet is what indexing a list of commits did, or on a dry run would do, with those of one set.

type LostLister

type LostLister interface {
	// LostVersions lists the versions of set the store cannot read, with
	// the commits each one damages.
	LostVersions(ctx context.Context, set string) ([]LostVersion, error)
}

LostLister is an index that knows which versions a repair could not keep.

type LostVersion

type LostVersion struct {
	Path    string
	Ref     *proto.Ref
	Commits []*proto.Ref
}

LostVersion is a stored version the store cannot read, with the live commits that hold it.

type OrphanCommit

type OrphanCommit struct {
	Ref *proto.Ref
	// Copies is how many committed archives hold the commit, and Bytes
	// what those copies take up.
	Copies int
	Bytes  int64
}

OrphanCommit is a commit the store holds that the index has no row for and no tombstone retires: retention never sees it, and every collection keeps what it reaches.

type OrphanFinder

type OrphanFinder interface {
	OrphanCommits(ctx context.Context) ([]OrphanCommit, error)
}

OrphanFinder is an index that finds the commits the store holds and it has no row for.

type RebuiltIndex

type RebuiltIndex struct {
	Name          string
	Before, After int64
}

RebuiltIndex is one index a reindex rebuilt, with its size in bytes before and after.

type Reindexed

type Reindexed struct {
	Table string
	// Churn is the rows inserted, updated and deleted since the table's
	// last reindex, and Live the rows it holds.
	Churn, Live int64
	Indexes     []RebuiltIndex
	Took        time.Duration
}

Reindexed is a table whose indexes a reindex rebuilt because enough of its rows changed since the last one.

type Retired

type Retired struct {
	Ref *proto.Ref
	// SetID and Set name the commit's set; a set's name is unique only
	// among the sets a caller sees.
	SetID int64
	Set   string
	// Timestamp is when the commit was taken and ReceivedAt when the store
	// received it.
	Timestamp, ReceivedAt time.Time
	// RetiredAt is when the policy retired the commit, zero for one deleted
	// by hand, and TombstonedAt when its tombstone became durable, zero
	// while none has.
	RetiredAt, TombstonedAt time.Time
	// Policy is the set's policy that retired the commit; nil when the
	// retirement predates its recording.
	Policy *retention.Policy
	// Deleted marks a commit deleted by hand, whose trash window let it go
	// unless retention did first.
	Deleted bool
	// Partial marks a checkpoint along the way of a backup.
	Partial bool
	// State is where the commit stands now.
	State RetiredState
}

Retired is a commit retention let go: when the set's policy retired it, when its tombstone became durable and under which policy.

type RetiredState

type RetiredState int

RetiredState is where a retired commit stands.

const (
	// RetiredPending is retired with its tombstone still to be written.
	RetiredPending RetiredState = iota
	// RetiredHeld is tombstoned while the store still holds the commit
	// object, so UnretireCommits may bring it back.
	RetiredHeld
	// RetiredGone is tombstoned and collected: the store holds no copy of
	// the commit object.
	RetiredGone
	// RetiredLive is live again, unretired since.
	RetiredLive
)

The states of a retired commit.

type SetInfo

type SetInfo struct {
	ID               int64
	Name             string
	State            string
	LogicalSize      int64
	KeptLogicalSize  int64
	PhysicalSize     int64
	DeduplicatedSize int64
	// UniqueSize is the size of every distinct file version a live commit
	// of the set holds, each counted once: what storing each version of
	// each file once would take.
	UniqueSize int64
	// AloneSize is what the set would take up were it the only set, and
	// ExclusiveSize what of that no other set holds, as of the last
	// garbage collection.
	AloneSize, ExclusiveSize int64
	// DeduplicatedAloneSize is DeduplicatedSize were the set the only set.
	DeduplicatedAloneSize int64
}

SetInfo is a set with, as the last measurement of its sets found them, the size of its newest live commit and the sizes of all its live commits added up, and, as of the last garbage collection, what its objects take up in the store and the size of the distinct content they carry before compression. A set never measured reports zero sizes.

type SetQuery

type SetQuery struct {
	// States keeps the sets in one of these states; none keeps all.
	States []string
	// Match keeps the sets whose name holds it, ignoring case, and those
	// Named lists; an empty Match keeps every set.
	Match string
	Named []string
	// BySize lists only the sets a garbage collection measured, largest
	// PhysicalSize first and by name within a size, instead of by name.
	BySize bool
	// After and AfterSize are the Name and PhysicalSize of the last set of
	// the previous page; AfterSize counts only with BySize. An empty After
	// starts at the first set.
	After     string
	AfterSize int64
	// Limit is the most sets a page holds; zero holds every one.
	Limit int
}

SetQuery picks and orders a page of sets. The zero SetQuery lists every set by name.

type SetRetention

type SetRetention struct {
	Policy    *retention.Policy
	Effective retention.Policy
	Paused    bool
}

SetRetention is a set's retention as an operator sees it: the policy set on it, nil when it inherits the store's, the policy in force, and whether retirement waits for a policy after a rebuild.

type SizeFiller

type SizeFiller interface {
	FillMissingSizes(ctx context.Context) (int, error)
}

SizeFiller is an index that works out the size of each commit it recorded without one.

type StorePolicy

type StorePolicy struct {
	Policy            storekey.Policy
	KeyAcknowledgedAt *time.Time
}

StorePolicy is the store's write policy with its acknowledgement state.

type Unretired

type Unretired struct {
	backup.Revival
	// Set names the commit's set.
	Set string
	// RetainedBy is why the set's policy keeps the commit once it is back,
	// as CommitDetail names it; empty when the policy retires it again or
	// the commit stays tombstoned.
	RetainedBy string
}

Unretired is what UnretireCommits did with one commit.

type Unretirer

type Unretirer interface {
	TombstonedCommits(ctx context.Context, set string, since time.Time) ([]*proto.Ref, error)
	UnretireCommits(ctx context.Context, refs []*proto.Ref, dryRun bool) ([]Unretired, error)
}

Unretirer is an index that brings tombstoned commits back.

type Version

type Version struct {
	Node *proto.TreeNode
	From time.Time
}

Version is one version of a path with From, when the store received the commit that first held it. No two versions of a path share a From.

type Windows

type Windows struct {
	TrashDays int
}

Windows are the store's trash window in days: how long a commit deleted by hand waits before its tombstone.

Directories

Path Synopsis
sql
Package sql is the index of a store: the commits, versions and pins of its sets with their retention state, the presence filters, the store settings and the archive index of the pack store, in one database that is SQLite for a local store and Postgres for a server.
Package sql is the index of a store: the commits, versions and pins of its sets with their retention state, the presence filters, the store settings and the archive index of the pack store, in one database that is SQLite for a local store and Postgres for a server.
ent
ent/schema
Package schema is the ent schema of the index: store settings, sets with their commits, versions, refs and retention state, pins, tombstoned refs and the archive index, in one database.
Package schema is the ent schema of the index: store settings, sets with their commits, versions, refs and retention state, pins, tombstoned refs and the archive index, in one database.
mapping
Package mapping turns index rows into the protos and structs the rest of goback speaks.
Package mapping turns index rows into the protos and structs the rest of goback speaks.
migrations
Package migrations holds the versioned migrations of the index, one directory per dialect, and applies them on open.
Package migrations holds the versioned migrations of the index, one directory per dialect, and applies them on open.
migrations/gen command
Command gen appends a migration to every dialect's directory when the ent schema changed.
Command gen appends a migration to every dialect's directory when the ent schema changed.
migrations/generate
Package generate writes the migration an ent schema change needs, for goback's own index and for anything built on goback that keeps its own schema the same way.
Package generate writes the migration an ent schema change needs, for goback's own index and for anything built on goback that keeps its own schema the same way.

Jump to

Keyboard shortcuts

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