Documentation
¶
Overview ¶
Package progress implements file transfer progress tracking with concurrent progress bars (Tracker) and a no-op implementation (Noop) for when tracking is disabled, both implementing the Trackable interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartSynthetic ¶ added in v0.1.5
func StartSynthetic( tracker *Tracker, key string, message string, valueLabel string, speedLabel string, stallFraction float64, ) func()
StartSynthetic creates and drives a synthetic progress entry identified by key. It is useful for operations that lack byte-level progress (like go install) but should still appear in the global progress list. The bar advances gradually and stalls once it reaches the given fraction (0 < stallFraction ≤ 1) until the returned function is invoked, at which point it completes instantly.
Types ¶
type Noop ¶
type Noop struct{}
Noop is a dummy progress tracker that implements the Trackable interface but performs no tracking. Useful when progress display is disabled.
func (*Noop) TrackProgress ¶
func (n *Noop) TrackProgress(_ string, _, _ int64, rc io.ReadCloser) io.ReadCloser
TrackProgress returns the unmodified stream without wrapping.
type Trackable ¶
type Trackable interface {
Start()
Wait()
TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser
}
Trackable defines the interface for progress tracking implementations.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker tracks multiple concurrent progress bars and renders them.
func (*Tracker) SetManualDisplay ¶ added in v0.1.5
SetManualDisplay customizes a tracker's presentation for sources without real byte progress (for example, go install). The supplied labels replace the rendered value and speed text while the message is updated to the provided string.
func (*Tracker) Start ¶
func (pt *Tracker) Start()
Start begins rendering progress bars in a separate goroutine.
func (*Tracker) TrackProgress ¶
func (pt *Tracker) TrackProgress( src string, currentSize, totalSize int64, stream io.ReadCloser, ) io.ReadCloser
TrackProgress wraps the given ReadCloser to update the progress bar during read and on close.