throttle

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ThrottledWriter

type ThrottledWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

ThrottledWriter is a writer that throttles what it writes it also implements io.ReaderFrom

func NewThrottleWriter

func NewThrottleWriter(w io.Writer, speed, minWrite int64) *ThrottledWriter

NewThrottleWriter creates a new throttledWriter writing in the provided io.Writer speed is the desired speed, while min and max Writes is the minimum or max writes that will be made at a time to the underlying writer. Notice: if minWrite is bigger than speed it will become equal to it.

func (*ThrottledWriter) ReadFrom

func (tw *ThrottledWriter) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads from the provided io.Reader while respecting the throttling

func (*ThrottledWriter) Write

func (tw *ThrottledWriter) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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