utils

package
v1.0.49 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package utils contains command functionality which is reused across multiple other packages.

Index

Constants

View Source
const MaxAttempts = 3

Variables

This section is empty.

Functions

func Retry added in v1.0.49

func Retry(f func() error) error

Retries the given function up to 3 times when it returns an RetryableError.

Types

type Progress added in v1.0.23

type Progress struct {
	BytesRead      int64
	BytesPerSecond int64
	Completed      bool
}

The Progress structure contains statistics about how many bytes have been read from the underlying reader.

func NewProgress added in v1.0.23

func NewProgress(bytesRead int64, bytesPerSecond int64, completed bool) *Progress

type ProgressBar added in v1.0.23

type ProgressBar struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

The ProgressBar helps rendering a text-based progress indicator on the command-line. It uses the standard error output interface of the logger for writing progress.

func NewProgressBar added in v1.0.23

func NewProgressBar(logger log.Logger) *ProgressBar

func (*ProgressBar) Remove added in v1.0.23

func (b *ProgressBar) Remove()

func (*ProgressBar) Update added in v1.0.23

func (b *ProgressBar) Update(text string, current int64, total int64, bytesPerSecond int64)

type ProgressReader added in v1.0.23

type ProgressReader struct {
	io.Reader
	ProgressFunc func(progress Progress)
	// contains filtered or unexported fields
}

The ProgressReader is a wrapper over the io.Reader interface which computes statistics while the data is read. This is used to show progress for file uploads and downloads.

The ProgressReader emits a Progress event whenever data is read from the reader. The event is debounced to avoid too many events.

func NewProgressReader added in v1.0.23

func NewProgressReader(reader io.Reader, progressFunc func(progress Progress)) *ProgressReader

func (*ProgressReader) Read added in v1.0.23

func (r *ProgressReader) Read(p []byte) (n int, err error)

type RetryableError added in v1.0.49

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

RetryableError can be returned inside of the Retry() block to indicate that the function failed and should be retried.

func Retryable added in v1.0.49

func Retryable(err error) *RetryableError

func (RetryableError) Error added in v1.0.49

func (e RetryableError) Error() string

Jump to

Keyboard shortcuts

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