ioutil

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferCloser added in v1.16.0

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

BufferCloser is a light wrapping around the bytes.Buffer that implements a "Close" method to return the buffer to a sync.Pool of buffers.

func NewBufferCloser added in v1.16.0

func NewBufferCloser() *BufferCloser

NewBufferCloser returns a new BufferCloser from the Buffer pool that has been reset.

func (*BufferCloser) Close added in v1.16.0

func (b *BufferCloser) Close() error

Close implements io.Closer. This will return the buffer to the buffer pool.

func (*BufferCloser) Read added in v1.16.0

func (b *BufferCloser) Read(p []byte) (n int, err error)

Read implements io.Reader

func (*BufferCloser) ReadFrom added in v1.16.0

func (b *BufferCloser) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom implements io.ReaderFrom

func (*BufferCloser) WriteTo added in v1.16.0

func (b *BufferCloser) WriteTo(w io.Writer) (n int64, err error)

WriteTo implements io.WriterTo

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