timeoutreader

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReadTimeout = errors.New("read timed out")

ErrReadTimeout is the error used when a read times out before completing.

Functions

This section is empty.

Types

type TimeoutReader

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

An io.ReadCloser that has a timeout for each underlying Read() function and optionally closes the underlying Reader on timeout.

func NewTimeoutReader

func NewTimeoutReader(reader io.ReadCloser, timeout time.Duration, closeOnTimeout bool) *TimeoutReader

Create a new TimeoutReader.

func NewTimeoutReaderSize

func NewTimeoutReaderSize(reader io.ReadCloser, timeout time.Duration, closeOnTimeout bool, maxReadSize int) *TimeoutReader

func (*TimeoutReader) Close

func (tr *TimeoutReader) Close() (err error)

Closes the TimeoutReader. Also closes the underlying Reader if it was not closed already at timeout.

func (*TimeoutReader) Read

func (tr *TimeoutReader) Read(p []byte) (int, error)

Read from the underlying reader. If the underlying Read() does not return within the timeout, ErrReadTimeout is returned.

Jump to

Keyboard shortcuts

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