record

package
v6.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package record holds a document shaped like one a handful of independent services would share: a row in a store, held as a serialized blob, whose fields are each owned by a different writer.

It exists for the contention benchmark. Whole-payload compare-and-swap conflicts whenever any field changes; a conditional patch conflicts only when the field its condition names changes. The fields here are deliberately independent so the difference between those two is what the benchmark measures.

Code generated by deep-gen. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var Fields = []string{
	"/stock", "/price", "/views", "/rating",
	"/reserved", "/shipped", "/returned", "/flagged",
}

Fields lists the JSON Pointer path of every service-owned counter, in the order the benchmark hands them out to writers.

Functions

This section is empty.

Types

type Record

type Record struct {
	ID      string `json:"id"`
	Version int    `json:"version"`

	Stock    int `json:"stock"`    // inventory service
	Price    int `json:"price"`    // pricing service, in cents
	Views    int `json:"views"`    // analytics
	Rating   int `json:"rating"`   // reviews
	Reserved int `json:"reserved"` // checkout
	Shipped  int `json:"shipped"`  // fulfilment
	Returned int `json:"returned"` // returns
	Flagged  int `json:"flagged"`  // moderation
}

Record is an inventory row. Version is what a compare-and-swap writer checks; the rest are owned one apiece by the services that update them.

func (*Record) Clone

func (t *Record) Clone() *Record

Clone returns a deep copy of t.

func (*Record) Diff

func (t *Record) Diff(other *Record) deep.Patch[Record]

Diff compares t with other and returns a Patch.

func (*Record) Equal

func (t *Record) Equal(other *Record) bool

Equal returns true if t and other are deeply equal.

func (*Record) Get

func (r *Record) Get(path string) int

Get returns the counter at one of the paths in Fields.

func (*Record) Patch

func (t *Record) Patch(p deep.Patch[Record], logger *slog.Logger) error

Patch applies p to t using the generated fast path.

func (*Record) Set

func (r *Record) Set(path string, v int)

Set writes the counter at one of the paths in Fields.

func (*Record) Total

func (r *Record) Total() int

Total sums every counter. The benchmark checks it against the number of successful writes: a lost update shows up as a shortfall.

Jump to

Keyboard shortcuts

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