file

package
v0.8.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: 8 Imported by: 0

Documentation

Overview

Package file is the JSONL file backend for payload logging: one Record per line. The zero-dependency default backend; the s3 backend (which pulls a cloud SDK and is excluded from minimal builds) lives alongside in pkg/payload/s3. Implements payload.Sink.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader is a payload.Reader backed by the same JSONL file Sink writes to. Get scans the file for the request id — fine for dogfood files (MB range). There is no List: the Logs list is served by the log store, not the body store.

func NewReader

func NewReader(path string) *Reader

NewReader constructs a Reader for path. Path must match the Sink the relay is currently writing to.

func (*Reader) Get

func (r *Reader) Get(_ context.Context, requestID string) (payload.Record, error)

Get scans for the record with the given request id, returning the newest match (a re-run reusing an id). Returns payload.ErrNotFound when absent or when the file doesn't exist yet.

type Sink

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

Sink appends one JSONL line per Record. Bodies serialize as base64 (json's []byte encoding), so the file is lossless for any content. Safe for concurrent Write via an internal mutex. Buffering is the OS's job — no userland buffer.

func NewSink

func NewSink(path string) (*Sink, error)

NewSink opens (creating, append-mode) path for the sink.

func NewSinkFromWriter

func NewSinkFromWriter(w io.Writer) *Sink

NewSinkFromWriter wraps an existing writer (tests, stdout).

func (*Sink) Close

func (s *Sink) Close() error

Close closes the underlying file (if NewSink opened one). Satisfies payload.Closer so the emitter flushes on shutdown.

func (*Sink) Write

func (s *Sink) Write(r payload.Record) error

Jump to

Keyboard shortcuts

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