progress

package module
v0.0.0-...-b1309e6 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCompleted = io.EOF

Functions

func IsCompleted

func IsCompleted(p Progressable) bool

func IsErrCompleted

func IsErrCompleted(err error) bool

func Stream

func Stream(ctx context.Context, progressable Progressable, interval time.Duration) <-chan Progress

func StreamMonitor

func StreamMonitor(ctx context.Context, monitor Monitorable, interval time.Duration) <-chan int64

func StreamMonitors

func StreamMonitors(ctx context.Context, monitors []Monitorable, interval time.Duration) <-chan []int64

Types

type AggregationStrategy

type AggregationStrategy int
const (
	DefaultStrategy AggregationStrategy = iota
	NormalizeStrategy
)

type Aggregator

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

func NewAggregator

func NewAggregator(strategy AggregationStrategy, p ...Progressable) *Aggregator

func (*Aggregator) Add

func (a *Aggregator) Add(p ...Progressable)

func (Aggregator) Current

func (a Aggregator) Current() int64

func (Aggregator) Error

func (a Aggregator) Error() error

func (*Aggregator) Progress

func (a *Aggregator) Progress() Progress

func (Aggregator) Size

func (a Aggregator) Size() int64

type Formatter

type Formatter func(Progress) (string, error)

type Generator

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

func NewGenerator

func NewGenerator(monitor Monitorable, sizer Sizable) *Generator

func (*Generator) Estimated

func (g *Generator) Estimated() time.Time

func (*Generator) Progress

func (g *Generator) Progress() Progress

func (*Generator) Remaining

func (g *Generator) Remaining() time.Duration

type Manual

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

func NewManual

func NewManual(size int64) *Manual

func (*Manual) Add

func (p *Manual) Add(n int64)

func (*Manual) Current

func (p *Manual) Current() int64

func (*Manual) Error

func (p *Manual) Error() error

func (*Manual) Increment

func (p *Manual) Increment()

func (*Manual) Progress

func (p *Manual) Progress() Progress

func (*Manual) Set

func (p *Manual) Set(n int64)

func (*Manual) SetCompleted

func (p *Manual) SetCompleted()

func (*Manual) SetError

func (p *Manual) SetError(err error)

func (*Manual) SetTotal

func (p *Manual) SetTotal(total int64)

func (*Manual) Size

func (p *Manual) Size() int64

type Monitorable

type Monitorable interface {
	Current() int64
	Error() error
}

type Progress

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

func (Progress) Complete

func (p Progress) Complete() bool

func (Progress) Current

func (p Progress) Current() int64

func (Progress) Error

func (p Progress) Error() error

func (Progress) Percent

func (p Progress) Percent() float64

func (Progress) Progress

func (p Progress) Progress() Progress

func (Progress) Ratio

func (p Progress) Ratio() float64

func (Progress) Size

func (p Progress) Size() int64

type Progressable

type Progressable interface {
	Monitorable
	Sizable
}

type Progressor

type Progressor interface {
	Progress() Progress
}

type Reader

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

Reader should wrap another reader (acts as a bytes pass through)

func NewProxyReader

func NewProxyReader(reader io.Reader, monitor *Manual) *Reader

func NewReader

func NewReader(reader io.Reader) *Reader

func NewSizedReader

func NewSizedReader(reader io.Reader, size int64) *Reader

func (*Reader) Current

func (r *Reader) Current() int64

func (*Reader) Error

func (r *Reader) Error() error

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

func (*Reader) SetCompleted

func (r *Reader) SetCompleted()

func (*Reader) SetReader

func (r *Reader) SetReader(reader io.Reader)

func (*Reader) Size

func (r *Reader) Size() int64

type Sizable

type Sizable interface {
	Size() int64
}

type Stage

type Stage struct {
	Current string
}

func (Stage) Stage

func (s Stage) Stage() string

type StagedMonitorable

type StagedMonitorable interface {
	Stager
	Monitorable
}

type StagedProgressable

type StagedProgressable interface {
	Stager
	Progressable
}

type StagedProgressor

type StagedProgressor interface {
	Stager
	Progressor
}

type Stager

type Stager interface {
	Stage() string
}

type TimeEstimator

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

func NewTimeEstimator

func NewTimeEstimator() TimeEstimator

func (*TimeEstimator) Estimated

func (t *TimeEstimator) Estimated() time.Time

func (*TimeEstimator) Remaining

func (t *TimeEstimator) Remaining() time.Duration

func (*TimeEstimator) Start

func (t *TimeEstimator) Start()

func (*TimeEstimator) Update

func (t *TimeEstimator) Update(p Progress)

type TimedProgress

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

func NewTimedProgress

func NewTimedProgress(duration time.Duration) *TimedProgress

func (*TimedProgress) Current

func (r *TimedProgress) Current() int64

func (*TimedProgress) Error

func (r *TimedProgress) Error() error

func (*TimedProgress) SetCompleted

func (r *TimedProgress) SetCompleted()

func (*TimedProgress) Size

func (r *TimedProgress) Size() int64

type Writer

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

Writer will consume a throw away bytes its given (not a passthrough). This is intended to be used with io.MultiWriter

func NewSizedWriter

func NewSizedWriter(size int64) *Writer

func NewWriter

func NewWriter() *Writer

func (*Writer) Current

func (w *Writer) Current() int64

func (*Writer) Error

func (w *Writer) Error() error

func (*Writer) SetComplete

func (w *Writer) SetComplete()

func (*Writer) Size

func (w *Writer) Size() int64

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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