valve

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 3 Imported by: 0

README

Valve

Regulate and meter I/O streams in Go

Go Reference Coverage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meter

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

Meter records the total bytes read and written, through the underlying io.Reader and io.Writer given at construction, using any of the following interfaces:

Constructors also exist for read-only, write-only, and read-write Meters. Methods without an underlying interface return io.ErrClosedPipe.

[Close] will close each underlying interface that implements io.Closer.

func NewMeter

func NewMeter(r io.Reader, w io.Writer) *Meter

NewMeter returns a new Meter that counts the total bytes read from r and written to w.

func NewReadMeter

func NewReadMeter(r io.Reader) *Meter

NewReadMeter returns a new Meter that counts the total bytes read from r.

func NewReadWriteMeter

func NewReadWriteMeter(rw io.ReadWriter) *Meter

NewReadWriteMeter returns a new Meter that counts the total bytes read from and written to rw.

func NewWriteMeter

func NewWriteMeter(w io.Writer) *Meter

NewWriteMeter returns a new Meter that counts the total bytes written to w.

func (*Meter) Close

func (m *Meter) Close() error

Close closes each underlying interface that implements io.Closer.

See io.Closer for details.

func (*Meter) Count

func (m *Meter) Count() (r, w int64)

Count returns the total bytes read and written.

func (*Meter) CountRead

func (m *Meter) CountRead() int64

CountRead returns the total bytes read.

func (*Meter) CountWritten

func (m *Meter) CountWritten() int64

CountWritten returns the total bytes written.

func (*Meter) Inc

func (m *Meter) Inc(nr, nw int64) (r, w int64)

Inc increments the total bytes read and written by nr and nw, respectively, and returns the new byte counts.

func (*Meter) IncRead

func (m *Meter) IncRead(n int64) int64

IncRead increments the total bytes read by n and returns the new byte count.

func (*Meter) IncWritten

func (m *Meter) IncWritten(n int64) int64

IncWritten increments the total bytes written by n and returns the new byte count.

func (*Meter) Read

func (m *Meter) Read(p []byte) (n int, err error)

Read writes the underlying io.Reader to p and increments the total bytes read by n.

See io.Reader for details.

func (*Meter) ReadFrom

func (m *Meter) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom copies from r to the underlying io.Writer and increments the total bytes written by n.

See io.ReaderFrom for details.

func (*Meter) Write

func (m *Meter) Write(p []byte) (n int, err error)

Write writes p to the underlying io.Writer and increments the total bytes written by n.

See io.Writer for details.

func (*Meter) WriteTo

func (m *Meter) WriteTo(w io.Writer) (n int64, err error)

WriteTo copies from the underlying io.Reader to w and increments the total bytes read by n.

See io.WriterTo for details.

Jump to

Keyboard shortcuts

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