iolimiter

package
v10.0.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRateLimitConn

func NewRateLimitConn(c net.Conn, readLimit, writeLimit float64) net.Conn

func NewReaderConn

func NewReaderConn(c net.Conn, bytesPerSec float64) net.Conn

NewtRateLimitReaderConn sets rate limit (bytes/sec) to the Conn read.

func NewWriterConn

func NewWriterConn(c net.Conn, bytesPerSec float64) net.Conn

NewtRateLimitWriterConn sets rate limit (bytes/sec) to the Conn write.

func NewtConn

func NewtConn(c net.Conn, bytesPerSec float64) net.Conn

NewtRateLimitConn sets rate limit (bytes/sec) to the Conn read and write.

Types

type Reader

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

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a reader that implements io.Reader with rate limiting.

func NewReaderWithContext

func NewReaderWithContext(r io.Reader, ctx context.Context) *Reader

NewReaderWithContext returns a reader that implements io.Reader with rate limiting.

func (*Reader) Read

func (s *Reader) Read(p []byte) (int, error)

Read reads bytes into p.

func (*Reader) SetRateLimit

func (s *Reader) SetRateLimit(bytesPerSec float64)

SetRateLimit sets rate limit (bytes/sec) to the reader.

type Writer

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

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a writer that implements io.Writer with rate limiting.

func NewWriterWithContext

func NewWriterWithContext(w io.Writer, ctx context.Context) *Writer

NewWriterWithContext returns a writer that implements io.Writer with rate limiting.

func (*Writer) SetRateLimit

func (s *Writer) SetRateLimit(bytesPerSec float64)

SetRateLimit sets rate limit (bytes/sec) to the writer.

func (*Writer) Write

func (s *Writer) Write(p []byte) (int, error)

Write writes bytes from p.

Jump to

Keyboard shortcuts

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