wiregolden

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package wiregolden renders the client requests of a capture as a normalized transcript, so that libfdb_c's and the Go client's requests for the same deterministic scenario can be compared line by line.

A scenario starts with a read of MarkerPrefix+name, so the transcript splits by scenario the same way for both clients; a marker named "~end" closes the last one. Within a scenario, requests are in the order they became readable at the capture point. What differs between runs is normalized, keeping equality: versions become V1, V2, ... and random byte strings (the 16 bytes of a self-conflicting key, idempotency IDs) become R1, R2, ... in order of appearance within the scenario. Reply tokens, span and debug IDs are left out. In key fields, the scenario's key prefix is written <p>; values are literal.

Index

Constants

View Source
const MarkerPrefix = "\x02wg/marker/"

MarkerPrefix is the key a scenario's marker read gets, followed by its name.

Variables

This section is empty.

Functions

func Transcript

func Transcript(reqs []Request, keyPrefix string, want []string) (string, error)

Transcript renders the requests of each scenario. Requests before the first marker (setup) and after the ~end marker are left out. It fails unless the markers are exactly want followed by ~end, on a scenario without a request, and on a request inside a scenario that the transcript does not decode (its fields would not be compared).

Types

type Capture

type Capture struct {
	Requests []Request
	// Other counts client frames of file identifiers the transcript does not
	// decode. They appear in the transcript as FileID(n), without fields.
	Other map[uint32]int
	// Undecodable counts frames of a decoded type that failed to parse.
	Undecodable int
	Complete    bool
}

Capture is a decoded capture.

func Decode

func Decode(r io.Reader, serverPorts []uint16) (*Capture, error)

Decode reads a pcap and decodes the client requests to serverPorts.

func DecodeWireLog

func DecodeWireLog(log []byte) (*Capture, error)

DecodeWireLog decodes the sends of a binary wire log (transport.CaptureWireLog): the client's requests, in the order it sent them.

type Request

type Request struct {
	TimeNS int64
	Seq    int // decode order, which breaks ties between equal times
	Kind   string
	Msg    any
}

Request is one decoded client request.

Jump to

Keyboard shortcuts

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