progress

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MinBytesForUpdate = 1024 * 1024 // 1MB

MinBytesForUpdate defines the minimum number of bytes that need to be transferred before sending a progress update

View Source
const UpdateInterval = 100 * time.Millisecond

UpdateInterval defines how often progress updates should be sent

Variables

This section is empty.

Functions

func NewReader

func NewReader(r io.Reader, updates chan<- oci.Update) io.Reader

NewReader returns a reader that reports progress to the given channel while reading.

func NewReaderWithOffset added in v1.0.4

func NewReaderWithOffset(r io.Reader, updates chan<- oci.Update, initialOffset int64) io.Reader

NewReaderWithOffset returns a reader that reports progress starting from an initial offset. This is useful for resuming interrupted downloads.

func PullMsg

func PullMsg(update oci.Update) string

func PushMsg

func PushMsg(update oci.Update) string

func WriteError

func WriteError(w io.Writer, message string, mode oci.Mode) error

WriteError writes an error message

func WriteProgress

func WriteProgress(w io.Writer, msg string, imageSize, layerSize, current uint64, layerID string, mode oci.Mode) error

WriteProgress writes a progress update message

func WriteSuccess

func WriteSuccess(w io.Writer, message string, mode oci.Mode) error

WriteSuccess writes a success message

func WriteWarning added in v1.0.4

func WriteWarning(w io.Writer, message string, mode oci.Mode) error

WriteWarning writes a warning message

Types

type Reader

type Reader struct {
	Reader       io.Reader
	ProgressChan chan<- oci.Update
	Total        int64
}

Reader wraps an io.Reader to track reading progress

func (*Reader) Read

func (pr *Reader) Read(p []byte) (int, error)

type Reporter

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

func NewProgressReporter

func NewProgressReporter(w io.Writer, msgF progressF, imageSize int64, layer oci.Layer, mode oci.Mode) *Reporter

func (*Reporter) Updates

func (r *Reporter) Updates() chan<- oci.Update

Updates returns a channel for receiving progress Updates. It is the responsibility of the caller to close the channel when they are done sending Updates. Should only be called once per Reporter instance.

func (*Reporter) Wait

func (r *Reporter) Wait() error

Wait waits for the progress Reporter to finish and returns any error encountered.

Jump to

Keyboard shortcuts

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