progress

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: 4 Imported by: 0

Documentation

Overview

Package progress reports how far a long-running store operation has got. A caller puts a Func in the context it runs the operation with; the operation reports each phase it enters and its counts as they move:

ctx = progress.NewContext(ctx, func(u progress.Update) { ... })
report, err := store.Collect(ctx, opts)

Index

Constants

View Source
const (
	OpCollect = "collect"
	OpCompact = "compact"
	OpRewrite = "rewrite"
	OpScrub   = "scrub"
	OpRetire  = "retire"
	OpReIndex = "reindex"
)

Operations, the Op of an Update.

View Source
const (
	// collect: snapshot, roots, mark, merge, confirm, then publish or
	// sweep, then purge.
	PhaseSnapshot = "snapshot"
	PhaseRoots    = "roots"
	PhaseMark     = "mark"
	PhaseMerge    = "merge"
	PhaseConfirm  = "confirm"
	PhasePublish  = "publish"
	PhaseSweep    = "sweep"
	PhasePurge    = "purge"
	// compact and rewrite.
	PhaseRewrite = "rewrite"
	// scrub.
	PhaseScrub = "scrub"
	// retire: due, tombstones, rows, prune.
	PhaseDue        = "due"
	PhaseTombstones = "tombstones"
	PhaseRows       = "rows"
	PhasePrune      = "prune"
	// reindex: tombstones, pins, commits, sets, policies, damage.
	PhasePins     = "pins"
	PhaseCommits  = "commits"
	PhaseSets     = "sets"
	PhasePolicies = "policies"
	PhaseDamage   = "damage"
)

Phases, the Phase of an Update. An operation enters its phases in the order listed for it and may skip some; RewritePlan enters its phase once per plan.

View Source
const Interval = time.Second

Interval is the least time between two updates of a phase, apart from the first and the last.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, fn Func) context.Context

NewContext returns a copy of ctx whose operations report to fn; a nil fn reports nothing.

Types

type Func

type Func func(Update)

Func receives the updates of the operations run with a context that carries it. One operation never calls it concurrently, but may call it from any of its goroutines, so it should return quickly. A Func shared by operations that run at the same time must be safe for concurrent use.

func FromContext

func FromContext(ctx context.Context) Func

FromContext returns the Func ctx carries, or nil.

type Phase

type Phase struct {
	// contains filtered or unexported fields
}

Phase counts the progress of one phase and reports it. Its methods are safe for concurrent use, and do nothing on a nil Phase.

func Start

func Start(ctx context.Context, op, phase string, total, bytesTotal int64) *Phase

Start reports that ctx's operation op entered phase, with the totals it knows, and returns the Phase to count it with. It returns nil when ctx carries no Func.

func (*Phase) Add

func (p *Phase) Add(done, bytes int64)

Add counts done more units and bytes more bytes, and reports them if the last update is at least Interval old.

func (*Phase) Finish

func (p *Phase) Finish()

Finish reports the phase's final counts. Nothing may Add after it.

type Update

type Update struct {
	Op, Phase         string
	Done, Total       int64
	Bytes, BytesTotal int64
}

Update is how far one phase of an operation has got. Done counts the phase's units (archives, root batches, commits, sets) and Bytes the bytes it has moved; a zero Total or BytesTotal means the phase does not know its total. Within a phase Done and Bytes never decrease.

Jump to

Keyboard shortcuts

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