circbuf

package
v0.8.18-rc-2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package circbuf provides an in-memory circular buffer implementation to bound the size of captured log streams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer represents a dynamic circular (ring) buffer. It will append data freely to the underlying buffer until maxSize is hit. Once hit, new writes will be written in a circular fashion.

func NewBuffer

func NewBuffer(maxSize int) (*Buffer, error)

NewBuffer creates and returns a Buffer pointer with a max size.

func (*Buffer) Bytes

func (c *Buffer) Bytes() []byte

Bytes returns the contents of the buffer, with the oldest contents at the beginning.

func (*Buffer) Size

func (c *Buffer) Size() int

Size returns the current size of the buffer.

func (*Buffer) TotalWritten

func (c *Buffer) TotalWritten() int

TotalWritten returns the total number of bytes written to the buffer.

func (*Buffer) Write

func (c *Buffer) Write(buf []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

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