progress

package
v0.0.1-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package progress logs bounded status lines for long-running loops, such as workers and pipelines, so operators can see what each one is doing without per-iteration log spam.

A Reporter collects counters between lines. Reporter.Tick logs at most one line per Interval while the loop did work, and at most one per IdleInterval while every counter stayed zero. Lines go to slog's default logger at Info level.

Index

Constants

View Source
const (
	Interval     = 15 * time.Second
	IdleInterval = time.Minute
)

Interval and IdleInterval bound how often a loop logs a status line.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reporter

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

Reporter accumulates named counters for one loop and logs them periodically. It is safe for concurrent use.

func New

func New(message string, attrs ...any) *Reporter

New returns a reporter whose lines carry message and attrs. The first line is due one Interval after creation.

func (*Reporter) Add

func (reporter *Reporter) Add(name string, delta int64)

Add increments a counter for the next line.

func (*Reporter) Tick

func (reporter *Reporter) Tick(ctx context.Context, status func() []any) bool

Tick logs the counters since the previous line, plus the attrs status returns, when a line is due, and then resets the counters. status is called only when a line is logged, so it may query state; it may be nil. Tick reports whether it logged.

Jump to

Keyboard shortcuts

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