Documentation ¶
Overview ¶
Package crdt implements CRDT types and associated changes
The main CRDT types are Dict and Seq which implement map-like and list-like container types.
The Container type can hold any mutable value.
Index ¶
- func BetweenOrd(a, b string, count int) []string
- func LessOrd(a, b string) bool
- func NextOrd(key string) string
- func PrevOrd(key string) string
- type Container
- func (c Container) Apply(ctx changes.Context, cx changes.Change) changes.Value
- func (c Container) Clone() Container
- func (c Container) Delete() (changes.Change, Container)
- func (c Container) Get() (*Rank, interface{})
- func (c Container) Set(r *Rank, v interface{}) (changes.Change, Container)
- func (c Container) Update(inner changes.Change) (changes.Change, Container)
- type Dict
- func (d Dict) Apply(ctx changes.Context, c changes.Change) changes.Value
- func (d Dict) Clone() Dict
- func (d Dict) Delete(key interface{}) (changes.Change, Dict)
- func (d Dict) Get(key interface{}) (*Rank, interface{})
- func (d Dict) Set(key, value interface{}) (changes.Change, Dict)
- func (d Dict) Update(key interface{}, inner changes.Change) (changes.Change, Dict)
- type Rank
- type Seq
- func (s Seq) Apply(ctx changes.Context, c changes.Change) changes.Value
- func (s Seq) Items() []interface{}
- func (s Seq) Move(offset, count, distance int) (changes.Change, Seq)
- func (s Seq) Splice(offset, remove int, replacement []interface{}) (changes.Change, Seq)
- func (s Seq) Update(idx int, inner changes.Change) (changes.Change, Seq)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BetweenOrd ¶
BetweenOrd returns keys between the two provided keys.
Types ¶
type Container ¶
Container holds a single CRDT value.
This is implemented as a map of unique rank to values. Every update creates a new entry in this map. Undo of an update causes the undo count for that rank to be incremented (and undo of the undo causes the count to be decremented).
Tho whole container itself can be deleted (with Deleted tracking the count) and undeleted.
type Dict ¶
type Dict struct {
Entries map[interface{}]Container
}
Dict implements a CRDT-style dictionary
type Rank ¶
Rank implements a unique ID that can be used for sorting.
The Epoch field is meant to track the time when the rank was created, so this can be used for garbage collection and such
Use Ord if it is important to generate specific sortable IDs with the ability to confine them between any two such values.