Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MP1COverwritingRingBuffer ¶
type MP1COverwritingRingBuffer[T any] struct { // contains filtered or unexported fields }
MP1COverwritingRingBuffer is a multi-producer, single-consumer ring buffer with a fixed size that overwrites the oldest item when full.
func NewMP1COverwritingRingBuffer ¶
func NewMP1COverwritingRingBuffer[T any](capacity uint64) *MP1COverwritingRingBuffer[T]
NewMP1COverwritingRingBuffer creates a ring buffer with capacity at least 'capacity', rounding up to the next power of two, so the ring won't grow infinitely.
func (*MP1COverwritingRingBuffer[T]) DumpN ¶
func (rb *MP1COverwritingRingBuffer[T]) DumpN(maxCount uint64) []T
DumpN reads up to 'maxCount' items in a single batch. Returns a slice of length <= maxCount. If empty, returns nil.
This is a single-consumer operation; only one goroutine should call DumpN.
func (*MP1COverwritingRingBuffer[T]) Enqueue ¶
func (rb *MP1COverwritingRingBuffer[T]) Enqueue(val T)
Enqueue writes 'val' into the ring buffer, overwriting the oldest entry if necessary. It never fails or blocks; producers always succeed.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements io.Writer and writes complete log lines to a ring buffer. It accumulates partial writes until a newline is seen.
func NewWriter ¶
func NewWriter(rb *MP1COverwritingRingBuffer[string]) *Writer
NewWriter returns a new Writer backed by the given ring buffer.