progress

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package progress defines the byte-counting reporter interface that long-running repo operations (CreateSnapshot, Restore, BackupPlan) surface progress through. The interface lives in its own package so the domain layer (internal/repo) doesn't have to import the UI layer (internal/ui) just to consume it — that prior layer inversion meant any future internal/sync, internal/daemon, or embedded SDK use of the repo package dragged in the entire Charmbracelet TUI dependency tree.

The dependency graph now flows in one direction:

tui → ui → progress ← repo ← cli

The CLI's *ui.ByteProgress and the test-only RecordingReporter here both satisfy Reporter; the TUI adapts events into tea.Msgs; callers that don't care about progress pass NopReporter so call sites don't need nil checks at every Add.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NopReporter

type NopReporter struct{}

NopReporter satisfies Reporter and discards every call. Repo callers that don't pass a reporter use this so the call sites don't need nil checks at every Add.

func (NopReporter) Add

func (NopReporter) Add(int64)

Add is a no-op.

func (NopReporter) Total

func (NopReporter) Total(int64)

Total is a no-op.

type RecordingReporter

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

RecordingReporter is a thread-safe Reporter that records every call. Tests use it to assert that the repo layer reports the right totals and progresses the right amounts.

func (*RecordingReporter) Add

func (r *RecordingReporter) Add(delta int64)

Add accumulates delta into done under the lock.

func (*RecordingReporter) Snapshot

func (r *RecordingReporter) Snapshot() (total, done int64, events int)

Snapshot returns the latest total, sum of Add deltas, and event count. Useful in tests to assert post-conditions without exporting the internal fields.

func (*RecordingReporter) Total

func (r *RecordingReporter) Total(n int64)

Total records the latest total under the lock.

type Reporter

type Reporter interface {
	Total(n int64)
	Add(delta int64)
}

Reporter is the contract long-running repo operations call into to surface byte-level progress.

Total is called once at the start with the total bytes the operation expects to process. It may be called again if the total is revised mid-operation (e.g. additional files discovered during a streaming walk). Add is called with positive deltas as bytes are processed.

Implementations must be safe for concurrent calls — repo operations fan out across worker pools and report from every worker.

Jump to

Keyboard shortcuts

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