progress

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyWithContext

func CopyWithContext(ctx context.Context, dst io.Writer, src io.Reader) (written int64, err error)

Types

type Callback

type Callback func(int64, io.Reader, io.Writer) error

Callback is a function that provides progress information copying from a Reader to a Writer

func BarCallback

func BarCallback(ctx context.Context) Callback

BarCallback returns a progress bar callback unless e.g. --quiet or lower loglevel is set

type DownloadBar

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

DownloadBar is a progress bar that implements the scs-library-client ProgressBar interface.

func (*DownloadBar) Abort

func (dpb *DownloadBar) Abort(drop bool)

func (*DownloadBar) IncrBy

func (dpb *DownloadBar) IncrBy(n int)

func (*DownloadBar) Init

func (dpb *DownloadBar) Init(contentLength int64)

func (*DownloadBar) ProxyReader

func (dpb *DownloadBar) ProxyReader(r io.Reader) io.ReadCloser

func (*DownloadBar) Wait

func (dpb *DownloadBar) Wait()

type RoundTripper

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

func NewRoundTripper

func NewRoundTripper(ctx context.Context, inner http.RoundTripper) *RoundTripper

NewRoundTripper wraps inner (or http.DefaultTransport if inner is nil) with progress bar functionality. A separate bar will be displayed for every GET request that returns a body >64KiB, updated as the response body is read. The caller is responsible for calling rt.ProgressWait / rt.ProgressShutdown when all requests are completed, so that the mpb progress container exits correctly. Note that if requests are made, but the response body is not read, the progress bar will remain 'stuck', preventing rt.ProgressWait from returning. rt.ProgressComplete is provided to override all bars to be 100% complete, to satisfy rt.ProgressWait where appropriate.

func (*RoundTripper) ProgressComplete added in v4.1.0

func (t *RoundTripper) ProgressComplete()

ProgressComplete overrides all progress bars, setting them to 100% complete.

func (*RoundTripper) ProgressShutdown added in v4.1.0

func (t *RoundTripper) ProgressShutdown()

ProgressShutdown immediately shuts down the mpb Progress container.

func (*RoundTripper) ProgressWait added in v4.1.0

func (t *RoundTripper) ProgressWait()

ProgressWait shuts down the mpb Progress container by waiting for all bars to complete.

func (*RoundTripper) RoundTrip

func (t *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type UploadBar

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

UploadBar is a progress bar that implements the scs-library-client UploadCallback interface.

func (*UploadBar) Finish

func (upb *UploadBar) Finish()

func (*UploadBar) GetReader

func (upb *UploadBar) GetReader() io.Reader

func (*UploadBar) IncrBy

func (upb *UploadBar) IncrBy(n int)

func (*UploadBar) Init

func (upb *UploadBar) Init(totalSize int64)

func (*UploadBar) InitUpload

func (upb *UploadBar) InitUpload(totalSize int64, r io.Reader)

func (*UploadBar) Terminate

func (upb *UploadBar) Terminate()

Jump to

Keyboard shortcuts

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