Documentation
¶
Overview ¶
Package payload is the storage contract for request/response body capture: the Record shape and the Sink/Reader interfaces its backends satisfy. The drivers live in pkg/payload/<backend>, and the lifecycle observer that produces Records lives in app/payloadlog (which re-exports these types).
A Record is the request/response bytes keyed by RequestID. Per-request metadata (status, routing, tokens, timing) lives on the log event (usage.Event) and is read via the log API. The body joins its log record by RequestID; the owner fields (project, principal, key hash) repeat the event's so the join can refuse a body that belongs to someone else.
Zero app/ or internal/ imports — this package is part of the vendorable surface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEraseUnsupported = errors.New("payload: backend cannot erase captured bodies")
ErrEraseUnsupported is returned by an Eraser that fronts a backend unable to delete captured bodies.
var ErrIntegrity = errors.New("payload: stored body fails its integrity check")
ErrIntegrity is returned by Reader.Get when a stored body no longer matches the digest taken when it was written. The body is withheld.
var ErrNotFound = errors.New("payload: record not found")
ErrNotFound is returned by Reader.Get when no captured Record exists for the requested id (the request ran without payload logging opted in, or the capture aged out). The HTTP layer maps it to 404 / "(not logged)".
Functions ¶
This section is empty.
Types ¶
type BatchWriter ¶ added in v0.11.7
type BatchWriter interface {
// WriteBatch delivers rs in order. An error may leave a prefix of the
// batch written; the emitter logs it and moves on, as for Write.
WriteBatch(rs []Record) error
}
BatchWriter is the optional bulk path of a Sink: the emitter hands each drained batch to WriteBatch in one call, and falls back to one Write per Record for a Sink without it. The slice is reused once the call returns.
type Closer ¶
type Closer interface {
Close() error
}
Closer is the optional shutdown contract for a Sink. The emitter type-asserts each sink for it and calls Close after the queue drains.
type EraseFilter ¶ added in v0.10.3
EraseFilter selects the records to erase by owner. At least one field is set; both narrow to one principal's records within one project.
type EraseResult ¶ added in v0.10.3
type EraseResult struct {
// Requests is the number of request records matched before deletion.
Requests uint64
}
EraseResult reports what an erase matched.
type Eraser ¶ added in v0.10.3
type Eraser interface {
Erase(ctx context.Context, f EraseFilter) (EraseResult, error)
}
Eraser deletes captured bodies. Implemented by backends that can.
type Reader ¶
type Reader interface {
// Get returns the captured Record for a single request id. Returns
// ErrNotFound when no capture exists for that id.
Get(ctx context.Context, requestID string) (Record, error)
}
Reader is the read-side counterpart to Sink. Body lookup is by request id only — there is no List/filter here, because the Logs list is driven by the log (usage) store, which holds all the metadata. The body is fetched on demand for the detail view.
type Record ¶
type Record struct {
RequestID string `json:"request_id"`
Timestamp time.Time `json:"ts"` // partitioning / TTL / keying only
ProjectID string `json:"project_id,omitempty"`
PrincipalID string `json:"principal_id,omitempty"`
RelayKeyHash string `json:"relay_key_hash,omitempty"`
RequestBody []byte `json:"request_body,omitempty"`
ResponseBody []byte `json:"response_body,omitempty"`
RequestTruncated bool `json:"request_truncated,omitempty"`
ResponseTruncated bool `json:"response_truncated,omitempty"`
}
Record is one captured request/response pair, keyed by RequestID. Bodies are stored raw; []byte marshals to base64 in JSON so file/object backends are lossless for non-UTF8 content.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package clickhouse provides a ClickHouse-backed implementation of payload.Sink, payload.Reader, and payload.Closer — the "text bodies in ClickHouse" backend for the Logs view.
|
Package clickhouse provides a ClickHouse-backed implementation of payload.Sink, payload.Reader, and payload.Closer — the "text bodies in ClickHouse" backend for the Logs view. |
|
Package dedup splits a JSON request body into a skeleton and content-addressed pieces, and rebuilds the exact bytes from them.
|
Package dedup splits a JSON request body into a skeleton and content-addressed pieces, and rebuilds the exact bytes from them. |
|
Package file is the JSONL file backend for payload logging: one Record per line.
|
Package file is the JSONL file backend for payload logging: one Record per line. |
|
Package s3 is the object-store backend for payload logging: one JSON object per Record.
|
Package s3 is the object-store backend for payload logging: one JSON object per Record. |