record

package
v6.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package record provides structured, deterministic operation recordings for workload tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithScope

func WithScope(ctx context.Context, scope Scope) context.Context

Types

type Operation

type Operation struct {
	Scope       Scope            `json:"scope"`
	Sequence    uint64           `json:"sequence"`
	Kind        string           `json:"kind"`
	Transaction uint64           `json:"transaction,omitempty"`
	Session     uint64           `json:"session,omitempty"`
	Statement   uint64           `json:"statement,omitempty"`
	QueryName   string           `json:"query_name,omitempty"`
	SQL         string           `json:"sql,omitempty"`
	Arguments   map[string]Value `json:"arguments,omitempty"`
	Isolation   string           `json:"isolation,omitempty"`
	Table       string           `json:"table,omitempty"`
	Columns     []string         `json:"columns,omitempty"`
	Method      string           `json:"method,omitempty"`
	Rows        int64            `json:"rows,omitempty"`
	Sample      [][]Value        `json:"sample,omitempty"`
	Error       string           `json:"error,omitempty"`
}

Operation is one query, transaction boundary or insertion.

type Recorder

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

Recorder is safe for concurrent workers. Zero value is ready for use. SampleRows bounds rows retained per insert; zero records counts only.

func (*Recorder) Add

func (r *Recorder) Add(operation Operation)

func (*Recorder) Answer

func (r *Recorder) Answer(sql string) Response

func (*Recorder) Begin

func (r *Recorder) Begin(scope Scope) uint64

func (*Recorder) Operations

func (r *Recorder) Operations() []Operation

Operations returns an owned snapshot sorted by scope, retaining local order.

func (*Recorder) Reply

func (r *Recorder) Reply(sql string, response Response)

Reply queues an answer for matching SQL; answers are consumed in call order. Use separate recorders when concurrent identical queries need distinct answers.

func (*Recorder) WriteTo

func (r *Recorder) WriteTo(output io.Writer) error

WriteTo emits one versioned JSON document, without runtime IDs or timings.

type Response

type Response struct {
	Columns []string
	Rows    [][]any
	Err     error
}

Response supplies an explicit answer to a query. Missing answers have no rows.

type Scope

type Scope struct {
	Database  string `json:"database"`
	Step      string `json:"step"`
	Worker    int    `json:"worker"`
	Iteration uint64 `json:"iteration"`
}

Scope identifies an operation stream; order is preserved within each stream.

func ContextScope

func ContextScope(ctx context.Context) Scope

type Value

type Value struct {
	Type string          `json:"type"`
	Data json.RawMessage `json:"value"`
}

Value retains the Go value type and its JSON representation, including NULL.

func Encode

func Encode(value any) (Value, error)

Jump to

Keyboard shortcuts

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