capture

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFrameSize     = 64 << 20
	MaxCaptureSize   = 256 << 20
	MaxCaptureFrames = 1 << 20
)

Variables

View Source
var (
	ErrRecorderClosed  = errors.New("capture recorder is closed")
	ErrFrameTooLarge   = errors.New("capture frame exceeds size limit")
	ErrCaptureTooLarge = errors.New("capture exceeds aggregate size limit")
	ErrTooManyFrames   = errors.New("capture exceeds frame count limit")
	ErrRecorderFailed  = errors.New("capture recorder entered failed state")
	ErrCaptureInUse    = errors.New("capture path is already owned by another recorder")
)
View Source
var (
	ErrCaptureBackpressure = errors.New("capture writer queue is full")
	ErrInsufficientDisk    = errors.New("capture minimum free disk threshold reached")
	ErrCloseDrainTimeout   = errors.New("capture writer close drain budget exceeded")
	ErrCorruptRecord       = errors.New("capture record failed integrity validation")
)

Functions

func MetadataPath

func MetadataPath(path string) string

func Replay

func Replay(path string) ([][]byte, error)

func ReplayContext

func ReplayContext(ctx context.Context, path string) ([][]byte, error)

ReplayContext validates the complete capture before allocating or returning frames. The aggregate limits bound the memory retained by the legacy Replay API; callers that need to process larger captures should use ReplayEachContext.

func ReplayEachContext

func ReplayEachContext(ctx context.Context, path string, submit func([]byte) error) error

ReplayEachContext snapshots and validates the entire source before invoking submit. This guarantees that a corrupt source never results in partial frame submission while keeping memory use bounded to one frame.

func ReplaySegments added in v0.0.2

func ReplaySegments(path string, submit func([]byte) error) error

ReplaySegments validates every record before submitting it.

func Validate

func Validate(path string) error

Validate checks a capture without retaining its frames in memory.

func ValidateContext

func ValidateContext(ctx context.Context, path string) error

ValidateContext checks a capture without retaining its frames in memory.

Types

type Direction

type Direction string
const (
	DirectionUnknown    Direction = "unknown"
	DirectionUpstream   Direction = "upstream"
	DirectionDownstream Direction = "downstream"
)

type FrameMetadata

type FrameMetadata struct {
	Index     uint64    `json:"index"`
	Direction Direction `json:"direction"`
	Timestamp time.Time `json:"timestamp"`
	Size      uint32    `json:"size"`
}

func ReplayMetadata

func ReplayMetadata(path string) ([]FrameMetadata, error)

type FrameRecorder added in v0.0.2

type FrameRecorder interface {
	WriteFrame(Direction, time.Time, []byte) error
	Close() error
}

type Recorder

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

func Start

func Start(path string) (*Recorder, error)

func (*Recorder) Close

func (r *Recorder) Close() error

func (*Recorder) Write

func (r *Recorder) Write(frame []byte) error

func (*Recorder) WriteFrame

func (r *Recorder) WriteFrame(direction Direction, timestamp time.Time, frame []byte) error

type SegmentOptions added in v0.0.2

type SegmentOptions struct {
	SegmentMaxBytes uint64
	RetainSegments  int
	MinFreeBytes    uint64
	QueueDepth      int
	CloseDrain      time.Duration
}

SegmentOptions controls the bounded, crash-detectable capture writer.

type SegmentedRecorder added in v0.0.2

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

SegmentedRecorder accepts owned copies of frames and serializes them on a bounded background writer. Segment files are published only after sync.

func StartSegmented added in v0.0.2

func StartSegmented(path string, options SegmentOptions) (*SegmentedRecorder, error)

func (*SegmentedRecorder) Close added in v0.0.2

func (r *SegmentedRecorder) Close() error

func (*SegmentedRecorder) Write added in v0.0.2

func (r *SegmentedRecorder) Write(frame []byte) error

func (*SegmentedRecorder) WriteFrame added in v0.0.2

func (r *SegmentedRecorder) WriteFrame(direction Direction, timestamp time.Time, frame []byte) error

Jump to

Keyboard shortcuts

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