register

package
v1.0.4-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package register implements state-based register CRDTs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidReplicaID = errors.New("register: invalid replica ID")
	ErrNilLWW           = errors.New("register: nil LWW register")
	ErrNilMax           = errors.New("register: nil max register")
	ErrTagConflict      = errors.New("register: conflicting value for one tag")
)

Functions

This section is empty.

Types

type LWW

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

LWW stores an opaque byte value selected by the greatest HLC tag. Values are copied at both API boundaries so callers cannot mutate converged state.

func NewLWW

func NewLWW(replicaID string) (*LWW, error)

func NewLWWFromClock

func NewLWWFromClock(state clock.State) (*LWW, error)

func (*LWW) ClockState

func (r *LWW) ClockState() clock.State

func (*LWW) Get

func (r *LWW) Get() ([]byte, bool)

func (*LWW) Merge

func (r *LWW) Merge(other *LWW) error

func (*LWW) Set

func (r *LWW) Set(value []byte) error

func (*LWW) State

func (r *LWW) State() crdt.StateSnapshot

type Max

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

Max is a grow-only register. A write below its current value is a no-op; Merge takes the maximum, which is associative, commutative, and idempotent.

func NewMax

func NewMax() *Max

func (*Max) Get

func (r *Max) Get() (uint64, bool)

func (*Max) Merge

func (r *Max) Merge(other *Max) error

func (*Max) Set

func (r *Max) Set(value uint64) error

func (*Max) State

func (r *Max) State() crdt.StateSnapshot

Jump to

Keyboard shortcuts

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