cacheseedbuffer

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cacheseedbuffer owns bounded recording of seed-reason-tagged HTTP requests.

Index

Constants

View Source
const DefaultCapacity = 1024

DefaultCapacity is the default ring buffer size for the cache-seed inspector. Sized to comfortably cover a cold-mount cascade without growing unboundedly in long-running sessions.

Variables

This section is empty.

Functions

func NewRecordingTransport

func NewRecordingTransport(base http.RoundTripper, buf *Buffer) http.RoundTripper

NewRecordingTransport wraps base (nil uses http.DefaultTransport) so that every request tagged with seedreason.Header is recorded to buf before being forwarded.

Types

type Buffer

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

Buffer is a goroutine-safe bounded ring buffer recording every tagged HTTP call the provider issues. Subscribers receive a snapshot of the current buffer plus any future appends until they stop reading.

func New

func New(capacity int) *Buffer

New constructs a new Buffer with the given capacity. A capacity of zero or less falls back to DefaultCapacity.

func (*Buffer) Capacity

func (b *Buffer) Capacity() int

Capacity returns the configured buffer capacity.

func (*Buffer) Record

func (b *Buffer) Record(reason seedreason.Reason, path string)

Record appends an entry to the buffer, evicting the oldest entry when the buffer is full. Safe to call concurrently from any goroutine.

func (*Buffer) Snapshot

func (b *Buffer) Snapshot() []Entry

Snapshot returns a copy of the current buffer contents in insertion order (oldest first).

func (*Buffer) Subscribe

func (b *Buffer) Subscribe() (snapshot []Entry, updates <-chan Entry, release func())

Subscribe returns a snapshot of the current buffer plus a channel that receives future appends. The caller must invoke the returned release function to remove its subscription and close the channel. The channel has a small buffer; if a slow consumer falls behind, newer entries are dropped rather than blocking the producer.

type Entry

type Entry struct {
	// TimestampMs is the unix timestamp in milliseconds when the request was
	// recorded (at dispatch time, not completion).
	TimestampMs int64
	// Reason is the seed-reason header value; empty if the request was not
	// tagged.
	Reason seedreason.Reason
	// Path is the URL path the request was sent to.
	Path string
}

Entry is a single recorded HTTP request tagged with a seed reason.

Jump to

Keyboard shortcuts

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