Documentation
¶
Index ¶
- type CRDT
- func (c *CRDT[T]) ApplyDelta(delta Delta[T]) bool
- func (c *CRDT[T]) CreateDelta(patch deep.Patch[T]) Delta[T]
- func (c *CRDT[T]) Edit(fn func(*T)) Delta[T]
- func (c *CRDT[T]) MarshalJSON() ([]byte, error)
- func (c *CRDT[T]) Merge(other *CRDT[T]) bool
- func (c *CRDT[T]) UnmarshalJSON(data []byte) error
- func (c *CRDT[T]) View() T
- type Delta
- type Text
- type TextRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CRDT ¶
type CRDT[T any] struct { Value T Clocks map[string]hlc.HLC Tombstones map[string]hlc.HLC NodeID string Clock *hlc.Clock // contains filtered or unexported fields }
CRDT represents a Conflict-free Replicated Data Type wrapper around type T.
func (*CRDT[T]) ApplyDelta ¶
ApplyDelta applies a delta using LWW resolution.
func (*CRDT[T]) CreateDelta ¶
CreateDelta takes an existing patch, applies it to the local value, updates local metadata, and returns a Delta. Use this if you have already generated a patch manually.
func (*CRDT[T]) MarshalJSON ¶
func (*CRDT[T]) UnmarshalJSON ¶
type Delta ¶
Delta represents a set of changes with a causal timestamp.
func (*Delta[T]) UnmarshalJSON ¶ added in v3.1.1
type Text ¶
type Text []TextRun
Text represents a CRDT-friendly text structure using runs.
type TextRun ¶
type TextRun struct {
ID hlc.HLC `deep:"key" json:"id"`
Value string `json:"v"`
Prev hlc.HLC `json:"p,omitempty"` // ID of the character this run follows
Deleted bool `json:"d,omitempty"` // Tombstone for CRDT convergence
}
TextRun represents a contiguous run of characters with a unique starting ID. Individual characters within the run have implicit IDs: ID + index.
Click to show internal directories.
Click to hide internal directories.