Documentation
¶
Overview ¶
Package cacheseedbuffer owns bounded recording of seed-reason-tagged HTTP requests.
Index ¶
Constants ¶
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 ¶
New constructs a new Buffer with the given capacity. A capacity of zero or less falls back to DefaultCapacity.
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 ¶
Snapshot returns a copy of the current buffer contents in insertion order (oldest first).
func (*Buffer) Subscribe ¶
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.