progress

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: PostgreSQL Imports: 11 Imported by: 0

Documentation

Overview

Package progress communicates and present multiple tasks progression.

A tasks leader initialize multiple progression. Each tasks defines its total, current value and progression message. Various presentation consumes progression events.

Current implementations includes CLI() for terminal and None() to discard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add added in v0.28.0

func Add(q int64)

Add quantity to total progression.

func CLI

func CLI(worker func() error) (err error)

CLI present progression in a tty

worker must call Clean().

Fallback to None() if stderr is not a TTY.

func Clean

func Clean()

Clean flushes progression

Worker leader must always call this If Init has not been called, tells presentation to skip.

Allows calling Init() again.

func Context

func Context(ctx context.Context, setters ...setter) (_ context.Context, done func())

Context initialize bar for ctx

A progression is attached to a context. However, Update() does not lock state. You must not share context to children goroutines. Only to function in the same goroutine.

Panics if all bars have been assigned to a context. Initialize state with setters. defer done function to ensure progress is complete at end of caller.

func Done

func Done() setter

Done marks ToDo as completed.

func Increment

func Increment(d int) setter

Increment updates progression current value

func Init

func Init(bars uint8)

Init a parallel progression

Must b called once in worker goroutine, before forking. Blocks until presentation goroutines is ready to consume progression.

Panics if another progression is tracking.

func Message

func Message(m string) setter

Message updates progression message

func Name

func Name(n string) setter

Name updates progression name

func None

func None(worker func() error) error

None does not present progression

func Rate added in v0.28.0

func Rate(r stringer) setter

Rate updates progression rate

func Terminate added in v0.28.0

func Terminate() setter

Terminate marks progression as complete.

Resets Total to Current.

func ToDo added in v0.28.0

func ToDo(q int64) setter

ToDo defines how much progression is expected on this bar.

Use Increment() to consume ToDo. Use Done() to mark ToDo as completed.

func Update

func Update(ctx context.Context, setters ...setter)

Update progression

Apply changes to progression assigned to context using Context(). May block if subscriber is behind. Closes subscriber once all bars are complete.

Types

This section is empty.

Jump to

Keyboard shortcuts

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