readwrite

package
v0.0.0-...-20e21a9 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExceeded = &Error{xerrors.New("bandwidth exceeded"), false, true}
	ErrDeadline = &Error{xerrors.New("deadline reached"), true, false}
)

Errors

Functions

This section is empty.

Types

type Error

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

An Error represents a readwrite error.

func (*Error) Temporary

func (e *Error) Temporary() bool

Temporary flag

func (*Error) Timeout

func (e *Error) Timeout() bool

Timeout flag

type Reader

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

Reader is a wrapper for io.Reader with throttling implemented

func NewReader

func NewReader(r io.Reader, limiter *limiter.Limiter, fragile bool) *Reader

NewReader makes the Reader instance r in an underlaing io.Reader limiter is a limiter instance to be used to contron Reader bandwidth fragile flags controls will the reader return an error on bandwidth exceeded, or will it retry until deadline.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read method to implement io.Reader interface

func (*Reader) SetDeadline

func (r *Reader) SetDeadline(t time.Time)

SetDeadline sets a deadline for the next Read.

type Writer

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

Writer is a wrapper for io.Writer with throttling implemented

func NewWriter

func NewWriter(w io.Writer, limiter *limiter.Limiter, fragile bool) *Writer

NewWriter makes the Writer instance w in an underlaing io.Writer limiter is a limiter instance to be used to contron Writer bandwidth fragile flags controlss will the writer return an error on bandwidth exceeded, or will it retry until deadline.

func (*Writer) SetDeadline

func (w *Writer) SetDeadline(t time.Time)

SetDeadline sets a deadline for the next Write.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write method to implement io.Writer interface

Jump to

Keyboard shortcuts

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