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 ¶
NewReadMeter simply wraps the given reader and returns a new ReadMeter
func (*ReadMeter) Close ¶
Close the underlying Reader if possible. This also unblocks any remaining waiters.
func (*ReadMeter) WaitForEOF ¶
func (rm *ReadMeter) WaitForEOF() <-chan struct{}
WaitForEOF, blocking until the reader encounters the io.EOF error
func (*ReadMeter) WaitForReading ¶
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