progress

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: BSD-2-Clause Imports: 4 Imported by: 1

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 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