meters

package
v0.0.0-...-d00ee4e Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2015 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

meters provide the ability to track usage of io.Writers and io.Readers.

Meters wrap the Writer/Reader by implementing the same interface. Each meter is also an io.Closer, even if the wrapped struct isn't. meter.Close() will halt all waiters and call the wrapped Close() method if it exists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadMeter

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

ReadMeter wraps an io.Reader to count the total bytes read

func NewReadMeter

func NewReadMeter(r io.Reader) *ReadMeter

NewReadMeter simply wraps the given reader and returns a new ReadMeter

func (*ReadMeter) Close

func (rm *ReadMeter) Close() error

Close the underlying Reader if possible. This also unblocks any remaining waiters.

func (*ReadMeter) Read

func (rm *ReadMeter) Read(p []byte) (n int, err error)

Read from the underlying io.Reader

func (*ReadMeter) Reading

func (rm *ReadMeter) Reading() int64

Reading is the count of total bytes read thus far

func (*ReadMeter) WaitForEOF

func (rm *ReadMeter) WaitForEOF() <-chan struct{}

WaitForEOF, blocking until the reader encounters the io.EOF error

func (*ReadMeter) WaitForReading

func (rm *ReadMeter) WaitForReading(reading int64) <-chan struct{}

WaitForReading will block until the specified total bytes are read

type WriteMeter

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

WriteMeter wraps an io.Writer to count the total bytes written

func NewWriteMeter

func NewWriteMeter(w io.Writer) *WriteMeter

NewWriteMeter simply wraps the given writer and returns a new WriteMeter

func (*WriteMeter) Close

func (wm *WriteMeter) Close() error

Close the underlying Writer if possible. This also unblocks any remaining waiters.

func (*WriteMeter) Reading

func (wm *WriteMeter) Reading() int64

Reading is the count of total bytes written thus far

func (*WriteMeter) WaitForReading

func (wm *WriteMeter) WaitForReading(reading int64) <-chan struct{}

WaitForReading will block until the specified total bytes are written

func (*WriteMeter) Write

func (wm *WriteMeter) Write(p []byte) (n int, err error)

Write to the underlying io.Writer

Jump to

Keyboard shortcuts

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