progress

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 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 reports the progress of messages send and its performance metrics.

A Reporter draws a progress bar, with the counts and an ETA, on stderr when progress was asked for, stderr is a terminal that acts on escape sequences and debug mode is off. In debug mode it logs each update as a debug line instead; otherwise it shows nothing. While the bar is drawn, everything else written to stderr goes through Writer, which moves the bar below it. Finish returns the send's Stats, which ShowMetrics prints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShowMetrics

func ShowMetrics(stats Stats, output io.Writer)

ShowMetrics displays performance metrics

Types

type Reporter

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

Reporter handles progress reporting for batch operations. Its methods may be called from several goroutines.

func NewReporter

func NewReporter(total int, showProgress, debugMode bool, output io.Writer) *Reporter

NewReporter creates a progress reporter that draws on output, stderr.

func (*Reporter) Finish

func (r *Reporter) Finish() Stats

Finish completes the progress reporting and returns stats

func (*Reporter) Record added in v0.3.0

func (r *Reporter) Record(sent, failed, unknown int)

Record reports the result of a finished send job: how many of its recipients were sent, how many failed and how many are of unknown outcome. The progress bar always shows the latest count.

func (*Reporter) Start

func (r *Reporter) Start()

Start initializes the progress reporter

func (*Reporter) Writer added in v0.3.0

func (r *Reporter) Writer(w io.Writer) io.Writer

Writer returns the writer of w, the output the reporter draws on, for everything else written to it while the bar may be drawn, such as notices and logs. Each write clears the bar's line first and draws the bar again below it, so neither runs into the other. Without a bar, it is w.

type Stats

type Stats struct {
	Total        int
	Sent         int
	Failed       int
	Unknown      int
	SuccessRate  float64
	Duration     time.Duration
	EmailsPerSec float64
}

Stats holds performance metrics. Unknown counts the recipients whose outcome is unknown: they may have been sent. SuccessRate is the share of the recipients with a result, sent, failed or unknown, that were sent.

Jump to

Keyboard shortcuts

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