s3-orchestrator

bufpool

import "github.com/afreidah/s3-orchestrator/internal/util/bufpool"

Package bufpool provides a shared pool of reusable byte buffers for streaming I/O, reducing GC pressure by replacing per-call allocations in io.Copy with pooled buffers via io.CopyBuffer.

Index

func Copy

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

Copy works like io.Copy but uses a pooled buffer to avoid per-call allocations. Safe for concurrent use.

func Get

func Get() *[]byte

Get returns a pooled buffer. The caller must call Put when done.

func GetWriter

func GetWriter(w io.Writer) *bufio.Writer

GetWriter returns a pooled bufio.Writer reset to write to w. The caller must call PutWriter when done. Flush before returning the writer to ensure all buffered data reaches the underlying writer.

func Put

func Put(b *[]byte)

Put returns a buffer to the pool for reuse.

func PutWriter

func PutWriter(bw *bufio.Writer)

PutWriter resets the writer (discarding any reference to the underlying writer) and returns it to the pool.

Generated by gomarkdoc