Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer is a high-throughput bounded circular ring buffer designed to decouple the real-time proxy data path from the asynchronous security analysis path.
func NewRingBuffer ¶
func NewRingBuffer(size int) *RingBuffer
NewRingBuffer creates a circular ring buffer with the given size (rounded up to power of 2).
func (*RingBuffer) Close ¶
func (rb *RingBuffer) Close()
Close shuts down the buffer and wakes up waiting consumers.
func (*RingBuffer) Pop ¶
func (rb *RingBuffer) Pop() *TrafficEvent
Pop retrieves the next event from the buffer. It blocks until an event is available or the buffer is closed.
func (*RingBuffer) Push ¶
func (rb *RingBuffer) Push(event *TrafficEvent) bool
Push adds an event to the ring buffer. It is completely non-blocking: if the analysis pipeline falls behind and the buffer is full, it drops the item and immediately returns to prevent any latency degradation in the proxy data path.
func (*RingBuffer) Stats ¶
func (rb *RingBuffer) Stats() (queued uint64, dropped uint64, total uint64)
Stats returns current operational metrics.
func (*RingBuffer) TryPop ¶
func (rb *RingBuffer) TryPop() *TrafficEvent
TryPop attempts to retrieve an event without blocking. Returns nil if empty.
type TrafficEvent ¶
type TrafficEvent struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Duration time.Duration `json:"duration_ns"`
ClientIP string `json:"client_ip"`
Scheme string `json:"scheme"`
Host string `json:"host"`
Method string `json:"method"`
Path string `json:"path"`
URL string `json:"url"`
Proto string `json:"proto"`
ReqHeaders http.Header `json:"req_headers"`
ReqBody []byte `json:"req_body"`
StatusCode int `json:"status_code"`
RespHeaders http.Header `json:"resp_headers"`
RespBody []byte `json:"resp_body"`
TLS bool `json:"tls"`
TLSServer string `json:"tls_server,omitempty"`
}
TrafficEvent captures the full request and response pair cloned from the data path.