ioutil

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rereader

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

Rereader has the ability to read the same io.Reader multiple times. There are currently some limitations to the design:

  • Reset MUST be called in order to Re-Read the reader.
  • Reset MUST be called after the ReReader is exausted (Read will return an io.EOF error).
  • Concurrent reads are not supported.

func NewRereader

func NewRereader(src io.Reader) (*Rereader, func())

NewRereader returns a new re-reader and closer that wraps the given reader. The re-reader consumes the given reader on demand, recording the entire stream so it can be replayed. The re-reader is suitable for retries. The re-reader does not support concurrent consumers, as would be necessary for speculative retries or fanout requests.

func (*Rereader) Read

func (rr *Rereader) Read(p []byte) (n int, err error)

Read implements the io.Reader interface. On the first read, we will record the entire contents of the source io.Reader for subsequent Reads.

func (*Rereader) Reset

func (rr *Rereader) Reset() error

Reset resets the rereader to read from the beginning of the source data. If the src has not finished reading, we will read the rest of the src data into the buffer.

Jump to

Keyboard shortcuts

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