Documentation
¶
Overview ¶
Package httpcapture owns the bounded, in-memory HTTP capture handoff. It does no I/O and starts no goroutines. Only framework packages can submit captures.
Index ¶
- Constants
- type Body
- type BodyEnd
- type Completion
- type Config
- type DropReason
- type Field
- type Metadata
- type ReadFailure
- type Record
- type Recorder
- func (r *Recorder) BodyBytes() int
- func (r *Recorder) Done() <-chan struct{}
- func (r *Recorder) Drain() *Record
- func (r *Recorder) Drops() [DropReasons]uint64
- func (r *Recorder) Lost(reason DropReason, records, carried uint64)
- func (r *Recorder) Ready() <-chan struct{}
- func (r *Recorder) Reserve() *Reservation
- func (r *Recorder) Seal()
- func (r *Recorder) Usage() (int, int64)
- type Reservation
- type Snapshot
Constants ¶
const ( ResponseBytes = 4 << 10 // MetadataBytes includes bounded strings, header entries, slice backing // arrays and snapshot bookkeeping, as well as the response head and the // bounded initial preread buffer during its one growth allocation. MetadataBytes = 96 << 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Completion ¶
type Completion struct {
Route string
Result observability.Result
Status value.Nullable[uint16] // actual committed status; absent on precommit abort/hijack
ResponseHead []byte
ResponseContentType, ResponseEncoding string
ResponseMetadataTruncated bool
ResponseTruncated bool
ResponseBytes int64 // accepted by the HTTP writer, not proof of delivery
Hijacked bool
Aborted bool
WriteFailed bool
Duration time.Duration
}
type Config ¶
Config contains operational limits only; it cannot select paths or body mode.
func DefaultConfig ¶
func DefaultConfig() Config
type DropReason ¶
type DropReason uint8
const ( DropSealed DropReason = iota DropRate DropCapacity DropBytes // DropWrite and DropShutdown are reported by the persistence owner after // it relinquishes records it could not store. DropWrite DropShutdown DropReasons )
type Metadata ¶
type Metadata struct {
RequestID attribution.RequestID
ReceivedAt time.Time
Prefix string
Full bool
Method string
EscapedPath string
RawQuery string
ClientIP netip.Addr
Headers []Field
ContentType string
ContentEncoding string
DeclaredBytes value.Nullable[int64]
PathTruncated, QueryTruncated, HeadersTruncated bool
MethodTruncated, ContentTypeTruncated, ContentEncodingTruncated bool
}
type ReadFailure ¶
type ReadFailure string
const ( ReadFailed ReadFailure = "read_failed" ReadTimeout ReadFailure = "read_timeout" ClientDisconnect ReadFailure = "client_disconnect" BodyLimit ReadFailure = "body_limit" )
type Record ¶
type Record struct {
Snapshot Snapshot
// contains filtered or unexported fields
}
Record is exclusively owned by the draining consumer, including its buffers.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder reserves both a slot and bytes before HTTP allocates capture data. Dequeued snapshots remain charged until their consumer releases them.
func (*Recorder) Drain ¶
Drain transfers one queued record without waiting. Release it only after all persistence/retry work has relinquished its snapshot.
func (*Recorder) Drops ¶
func (r *Recorder) Drops() [DropReasons]uint64
Drops returns owned cumulative counters indexed by DropReason.
func (*Recorder) Lost ¶
func (r *Recorder) Lost(reason DropReason, records, carried uint64)
Lost counts captures the consumer could not store, including the loss counts those records carried, so the next completed record reports them.
func (*Recorder) Reserve ¶
func (r *Recorder) Reserve() *Reservation
Reserve never waits for capacity, a consumer, or I/O.
type Reservation ¶
type Reservation struct {
// contains filtered or unexported fields
}
func (*Reservation) Complete ¶
func (l *Reservation) Complete(snapshot Snapshot)
Complete takes exclusive ownership of every snapshot buffer. The HTTP owner must never mutate or retain those buffers after this call.