Skip to content

Backend RingBuffer

Eduard Mishkurov edited this page Jun 10, 2026 · 1 revision

Ring Buffer Backend

RingBufferBackend is an in-memory backend that keeps only the last N formatted records.

It is intended for diagnostics, tests, and recent-history capture where keeping the complete log stream is unnecessary.


Behavior

Implementation behavior:

  • each accepted record is formatted using the owner channel’s OutputFlags
  • records are stored as strings
  • appending is protected by an internal mutex
  • when the record count exceeds max-items, the oldest records are removed
  • Join() returns the current ring content as one string
  • Clear() drops the current records

Configuration

RingBufferBackendConfig::Parse() supports:

  • max-items — positive integer number of records to keep

Example:

{
  "type": "RingBufferBackend",
  "max-items": 200
}

max-items must be greater than zero.


Runtime control

The backend command accepts the type names ringbuffer, ring, and rbuf:

logmectl -p 9010 backend --channel net --add ring --max-items 200

--max-items applies only to RingBufferBackend.


Relationship to BufferBackend

BufferBackend and RingBufferBackend are both memory backends, but they solve different problems:

  • BufferBackend stores a byte buffer and is useful for delayed persistence or complete in-memory capture.
  • RingBufferBackend stores the last N records and is useful for recent-history diagnostics.

See Recent-History Capture for the diagnostic pattern built on top of this backend.

Clone this wiki locally