buffer

package
v3.76.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package buffer provides a custom buffer type that includes metrics for tracking buffer usage. It also provides a pool for managing buffer reusability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadCloser

func ReadCloser(data []byte, onClose func()) *readCloser

ReadCloser creates a new instance of readCloser.

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

Buffer is a wrapper around bytes.Buffer that includes a timestamp for tracking Buffer checkout duration.

func NewBuffer

func NewBuffer() *Buffer

NewBuffer creates a new instance of Buffer.

func (*Buffer) Grow

func (b *Buffer) Grow(size int)

func (*Buffer) Write

func (b *Buffer) Write(data []byte) (int, error)

Write date to the buffer.

type Pool

type Pool struct {
	*sync.Pool
	// contains filtered or unexported fields
}

Pool of buffers.

func NewBufferPool

func NewBufferPool(opts ...PoolOpts) *Pool

NewBufferPool creates a new instance of BufferPool.

func (*Pool) Get

func (p *Pool) Get() *Buffer

Get returns a Buffer from the pool.

func (*Pool) Put

func (p *Pool) Put(buf *Buffer)

Put returns a Buffer to the pool.

type PoolOpts

type PoolOpts func(pool *Pool)

PoolOpts is a function that configures a BufferPool.

Jump to

Keyboard shortcuts

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