progressreader

package
v1.4.2-0...-b0dc111 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package progressreader provides a Reader with a progress bar that can be printed out using the streamformatter package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Broadcaster keeps track of one or more observers watching the progress of an operation. For example, if multiple clients are trying to pull an image, they share a Broadcaster for the download operation.

func NewBroadcaster

func NewBroadcaster() *Broadcaster

NewBroadcaster returns a Broadcaster structure

func (*Broadcaster) Add

func (broadcaster *Broadcaster) Add(w io.Writer) error

Add adds an observer to the Broadcaster. The new observer receives the data from the history buffer, and also all subsequent data.

func (*Broadcaster) Close

func (broadcaster *Broadcaster) Close()

Close signals to all observers that the operation has finished. It causes all calls to Wait to return nil.

func (*Broadcaster) CloseWithError

func (broadcaster *Broadcaster) CloseWithError(result error)

CloseWithError signals to all observers that the operation has finished. Its argument is a result that should be returned to waiters blocking on Wait.

func (*Broadcaster) Wait

func (broadcaster *Broadcaster) Wait() error

Wait blocks until the operation is marked as completed by the Close method, and all writer goroutines have completed. It returns the argument that was passed to Close.

func (*Broadcaster) Write

func (broadcaster *Broadcaster) Write(p []byte) (n int, err error)

Write adds data to the history buffer, and also writes it to all current observers.

type Config

type Config struct {
	In         io.ReadCloser // Stream to read from
	Out        io.Writer     // Where to send progress bar to
	Formatter  *streamformatter.StreamFormatter
	Size       int64
	Current    int64
	LastUpdate int64
	NewLines   bool
	ID         string
	Action     string
}

Config contains the configuration for a Reader with progress bar.

func New

func New(newReader Config) *Config

New creates a new Config.

func (*Config) Close

func (config *Config) Close() error

Close closes the reader (Config).

func (*Config) Read

func (config *Config) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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