streamio

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(dst io.Writer, src io.Reader) (written int64, err error)

Copy copy reader to writer

func GetBufferWriter

func GetBufferWriter(writer io.Writer) *bufio.Writer

GetBufferWriter returns a *bufio.Writer that is managed by a sync.Pool. Returns a bufio.Writer that is reset with writer and ready for use.

After use, the *bufio.Writer should be put back into the sync.Pool by calling PutBufferWriter.

func GetBufioReader

func GetBufioReader(reader io.Reader) *bufio.Reader

GetBufioReader returns a *bufio.Reader that is managed by a sync.Pool. Returns a bufio.Reader that is reset with reader and ready for use.

After use, the *bufio.Reader should be put back into the sync.Pool by calling PutBufioReader.

func GetByteSlice

func GetByteSlice() *[]byte

GetByteSlice returns a *[]byte that is managed by a sync.Pool. The initial slice length will be 16384 (16kb).

After use, the *[]byte should be put back into the sync.Pool by calling PutByteSlice.

func GetBytesBuffer

func GetBytesBuffer() *bytes.Buffer

GetBytesBuffer returns a *bytes.Buffer that is managed by a sync.Pool. Returns a buffer that is reset and ready for use.

After use, the *bytes.Buffer should be put back into the sync.Pool by calling PutBytesBuffer.

func GetZlibWriter

func GetZlibWriter(w io.Writer) *zlib.Writer

GetZlibWriter returns a *zlib.Writer that is managed by a sync.Pool. Returns a writer that is reset with w and ready for use.

After use, the *zlib.Writer should be put back into the sync.Pool by calling PutZlibWriter.

func GrowReadMax

func GrowReadMax(r io.Reader, n int64, grow int) ([]byte, error)

func LargeCopy

func LargeCopy(dst io.Writer, src io.Reader) (written int64, err error)

func PutBufferWriter

func PutBufferWriter(writer *bufio.Writer)

PutBufferWriter puts reader back into its sync.Pool.

func PutBufioReader

func PutBufioReader(reader *bufio.Reader)

PutBufioReader puts reader back into its sync.Pool.

func PutByteSlice

func PutByteSlice(buf *[]byte)

PutByteSlice puts buf back into its sync.Pool.

func PutBytesBuffer

func PutBytesBuffer(buf *bytes.Buffer)

PutBytesBuffer puts buf back into its sync.Pool.

func PutZlibReader

func PutZlibReader(z *ZLibReader)

PutZlibReader puts z back into its sync.Pool, first closing the reader. The Byte slice dictionary is also put back into its sync.Pool.

func PutZlibWriter

func PutZlibWriter(w *zlib.Writer)

PutZlibWriter puts w back into its sync.Pool.

func PutZstdReader

func PutZstdReader(z *ZstdDecoder)

PutZstdReader puts z back into its sync.Pool, first closing the reader. The Byte slice dictionary is also put back into its sync.Pool.

func PutZstdWriter

func PutZstdWriter(w *ZstdEncoder)

PutZstdWriter puts w back into its sync.Pool.

func ReadMax

func ReadMax(r io.Reader, n int64) ([]byte, error)

Types

type ZLibReader

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

func GetZlibReader

func GetZlibReader(r io.Reader) (*ZLibReader, error)

GetZlibReader returns a ZLibReader that is managed by a sync.Pool. Returns a ZLibReader that is reset using a dictionary that is also managed by a sync.Pool.

After use, the ZLibReader should be put back into the sync.Pool by calling PutZlibReader.

type ZstdDecoder

type ZstdDecoder struct {
	*zstd.Decoder
}

func GetZstdReader

func GetZstdReader(r io.Reader) (*ZstdDecoder, error)

GetZstdReader returns a ZstdDecoder that is managed by a sync.Pool. Returns a ZLibReader that is reset using a dictionary that is also managed by a sync.Pool.

After use, the ZstdDecoder should be put back into the sync.Pool by calling PutZstdReader.

type ZstdEncoder

type ZstdEncoder struct {
	*zstd.Encoder
}

func GetZstdWriter

func GetZstdWriter(w io.Writer) *ZstdEncoder

GetZstdWriter returns a *ztsd.Encoder that is managed by a sync.Pool. Returns a writer that is reset with w and ready for use.

After use, the *ztsd.Encoder should be put back into the sync.Pool by calling PutZstdWriter.

Jump to

Keyboard shortcuts

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