geario

package module
v0.0.0-...-ddc203b Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: MIT Imports: 9 Imported by: 2

README

geario

Build Status Go Report Card GoDoc GitHub license gocover.io

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesSize

func BytesSize(size B) string

BytesSize returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").

func ConnGear

func ConnGear(rw net.Conn, r, w *Gear) net.Conn

func CustomSize

func CustomSize(format string, size B, base B, _map []string) string

CustomSize returns a human-readable approximation of a size using custom format.

func GearConn

func GearConn(conn net.Conn, duration time.Duration, limit B) net.Conn

GearConn is limit the speed of reading and writing from net.Conn

func GearReadWriter

func GearReadWriter(rw io.ReadWriter, duration time.Duration, limit B) io.ReadWriter

GearReadWriter is limit the speed of reading and writing from io.ReadWriter

func GearReader

func GearReader(r io.Reader, duration time.Duration, limit B) io.Reader

GearReader is limit the speed of reading from io.Reader

func GearWriter

func GearWriter(w io.Writer, duration time.Duration, limit B) io.Writer

GearWriter is limit the speed of writing to io.Writer

func HumanSizeWithPrecision

func HumanSizeWithPrecision(size B, precision int) string

HumanSizeWithPrecision allows the size to be in any precision

func ReadWriterGear

func ReadWriterGear(rw io.ReadWriter, r, w *Gear) io.ReadWriter

Types

type B

type B float64
const (
	KB B = 1000
	MB B = 1000 * KB
	GB B = 1000 * MB
	TB B = 1000 * GB
	PB B = 1000 * TB
	EB B = 1000 * PB
	ZB B = 1000 * EB
	YB B = 1000 * ZB

	KiB B = 1024
	MiB B = 1024 * KiB
	GiB B = 1024 * MiB
	TiB B = 1024 * GiB
	PiB B = 1024 * TiB
	EiB B = 1024 * PiB
	ZiB B = 1024 * EiB
	YiB B = 1024 * ZiB
)

See: http://en.wikipedia.org/wiki/Binary_prefix

func FromBytesSize

func FromBytesSize(size string) (B, error)

FromBytesSize returns an integer from a human-readable specification of a size using binary standard (eg. "44kiB", "17MiB").

func FromHumanSize

func FromHumanSize(size string) (B, error)

FromHumanSize returns an integer from a human-readable specification of a size using SI standard (eg. "44kB", "17MB").

func (B) String

func (b B) String() string

type BPS

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

func NewBPSAver

func NewBPSAver(r time.Duration) *BPS

func (*BPS) Add

func (p *BPS) Add(b B)

func (*BPS) Aver

func (p *BPS) Aver() B

func (*BPS) MaxAver

func (p *BPS) MaxAver() B

func (*BPS) Next

func (p *BPS) Next() time.Time

func (*BPS) String

func (p *BPS) String() string

type Gear

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

func NewGear

func NewGear(duration time.Duration, limit B) *Gear

func (*Gear) Aver

func (g *Gear) Aver() B

func (*Gear) BPS

func (g *Gear) BPS() *BPS

func (*Gear) Conn

func (g *Gear) Conn(rw net.Conn) net.Conn

func (*Gear) LastAver

func (g *Gear) LastAver() B

func (*Gear) Limit

func (g *Gear) Limit() B

func (*Gear) MaxAver

func (g *Gear) MaxAver() B

func (*Gear) ReadWriter

func (g *Gear) ReadWriter(rw io.ReadWriter) io.ReadWriter

func (*Gear) Reader

func (g *Gear) Reader(r io.Reader) io.Reader

func (*Gear) SetLimit

func (g *Gear) SetLimit(b B)

func (*Gear) Total

func (g *Gear) Total() B

func (*Gear) Writer

func (g *Gear) Writer(w io.Writer) io.Writer

Jump to

Keyboard shortcuts

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