cursor

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindInteger = "integer"
	KindVector  = "vector"
)

Variables

This section is empty.

Functions

func EncodeUvarint

func EncodeUvarint(u uint64) []byte

Optional: compact binary helpers if you later want non-JSON wire payloads.

func InitDefaultCodecs

func InitDefaultCodecs()

func Register

func Register(c Codec)

func ValidateWireCursor

func ValidateWireCursor(wc *WireCursor) error

Types

type Codec

type Codec interface {
	Kind() string
	Marshal(c Cursor) (json.RawMessage, error)      // returns the Data part only
	Unmarshal(data json.RawMessage) (Cursor, error) // parse Data into a Cursor
}

Codec for marshaling/unmarshaling cursors to a stable wire form.

func Lookup

func Lookup(kind string) (Codec, bool)

type ConcurrentTestCodec

type ConcurrentTestCodec struct {
	ID string
}

ConcurrentTestCodec is a test-only codec for concurrent registry tests

func (ConcurrentTestCodec) Kind

func (c ConcurrentTestCodec) Kind() string

func (ConcurrentTestCodec) Marshal

func (ConcurrentTestCodec) Unmarshal

func (ConcurrentTestCodec) Unmarshal(data json.RawMessage) (Cursor, error)

type Cursor

type Cursor interface {
	Kind() string
}

func MustUnmarshalWire added in v0.10.0

func MustUnmarshalWire(data []byte) Cursor

MustUnmarshalWire unmarshals a WireCursor to a Cursor, panicking on error This is useful for cases where the wire cursor is known to be valid

func UnmarshalWire

func UnmarshalWire(wc *WireCursor) (Cursor, error)

type IntegerCursor

type IntegerCursor struct {
	Seq uint64
}

IntegerCursor is a simple high-water mark (seq).

func NewInteger added in v0.10.0

func NewInteger(seq uint64) IntegerCursor

NewInteger creates a new IntegerCursor with the given sequence number

func (IntegerCursor) Compare

func (ic IntegerCursor) Compare(other types.Version) int

Compare implements types.Version

func (IntegerCursor) IsZero

func (ic IntegerCursor) IsZero() bool

IsZero implements types.Version

func (IntegerCursor) Kind

func (IntegerCursor) Kind() string

func (IntegerCursor) String

func (ic IntegerCursor) String() string

String implements types.Version

type VectorCursor

type VectorCursor struct {
	Counters map[string]uint64
}

VectorCursor is a dotted-vector summary: map[node]counter

func NewVector added in v0.10.0

func NewVector(counters map[string]uint64) VectorCursor

NewVector creates a new VectorCursor with the given counters

func (VectorCursor) Compare

func (vc VectorCursor) Compare(other types.Version) int

Compare implements types.Version

func (VectorCursor) IsZero

func (vc VectorCursor) IsZero() bool

IsZero implements types.Version

func (VectorCursor) Kind

func (VectorCursor) Kind() string

func (VectorCursor) String

func (vc VectorCursor) String() string

String implements types.Version

type WireCursor

type WireCursor struct {
	Kind string          `json:"kind"`
	Data json.RawMessage `json:"data"`
}

WireCursor is the typed union for transport (HTTP JSON).

func MarshalWire

func MarshalWire(c Cursor) (*WireCursor, error)

func MustMarshalWire added in v0.10.0

func MustMarshalWire(c Cursor) WireCursor

MustMarshalWire marshals a cursor to WireCursor format, panicking on error This is useful for cases where the cursor is known to be valid

Jump to

Keyboard shortcuts

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