progress

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter struct {
	Updater
	// contains filtered or unexported fields
}

A Counter tracks a running count and controls a goroutine that passes its value periodically to a Func.

The Func is also called when SIGUSR1 (or SIGINFO, on BSD) is received.

func NewCounter

func NewCounter(interval time.Duration, total uint64, report Func) *Counter

NewCounter starts a new Counter.

func (*Counter) Add

func (c *Counter) Add(v uint64)

Add v to the Counter. This method is concurrency-safe.

func (*Counter) Done

func (c *Counter) Done()

func (*Counter) Get

func (c *Counter) Get() (v, max uint64)

Get returns the current value and the maximum of c. This method is concurrency-safe.

func (*Counter) SetMax

func (c *Counter) SetMax(max uint64)

SetMax sets the maximum expected counter value. This method is concurrency-safe.

type Func

type Func func(value uint64, total uint64, runtime time.Duration, final bool)

A Func is a callback for a Counter.

The final argument is true if Counter.Done has been called, which means that the current call will be the last.

type NoopPrinter added in v0.17.0

type NoopPrinter struct{}

NoopPrinter discards all messages

func (*NoopPrinter) E added in v0.17.0

func (*NoopPrinter) E(_ string, _ ...interface{})

func (*NoopPrinter) NewCounter added in v0.17.0

func (*NoopPrinter) NewCounter(_ string) *Counter

func (*NoopPrinter) P added in v0.17.0

func (*NoopPrinter) P(_ string, _ ...interface{})

func (*NoopPrinter) V added in v0.17.0

func (*NoopPrinter) V(_ string, _ ...interface{})

func (*NoopPrinter) VV added in v0.17.0

func (*NoopPrinter) VV(_ string, _ ...interface{})

type Printer added in v0.17.0

type Printer interface {
	NewCounter(description string) *Counter

	E(msg string, args ...interface{})
	P(msg string, args ...interface{})
	V(msg string, args ...interface{})
	VV(msg string, args ...interface{})
}

A Printer can can return a new counter or print messages at different log levels. It must be safe to call its methods from concurrent goroutines.

type TestPrinter added in v0.17.0

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

TestPrinter prints messages during testing

func NewTestPrinter added in v0.17.0

func NewTestPrinter(t testing.TB) *TestPrinter

func (*TestPrinter) E added in v0.17.0

func (p *TestPrinter) E(msg string, args ...interface{})

func (*TestPrinter) NewCounter added in v0.17.0

func (p *TestPrinter) NewCounter(_ string) *Counter

func (*TestPrinter) P added in v0.17.0

func (p *TestPrinter) P(msg string, args ...interface{})

func (*TestPrinter) V added in v0.17.0

func (p *TestPrinter) V(msg string, args ...interface{})

func (*TestPrinter) VV added in v0.17.0

func (p *TestPrinter) VV(msg string, args ...interface{})

type UpdateFunc

type UpdateFunc func(runtime time.Duration, final bool)

An UpdateFunc is a callback for a (progress) Updater.

The final argument is true if Updater.Done has been called, which means that the current call will be the last.

type Updater

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

An Updater controls a goroutine that periodically calls an UpdateFunc.

The UpdateFunc is also called when SIGUSR1 (or SIGINFO, on BSD) is received.

func NewUpdater

func NewUpdater(interval time.Duration, report UpdateFunc) *Updater

NewUpdater starts a new Updater.

func (*Updater) Done

func (c *Updater) Done()

Done tells an Updater to stop and waits for it to report its final value. Later calls do nothing.

Jump to

Keyboard shortcuts

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