Documentation
¶
Index ¶
- type CrdtEngine
- type Element
- type LWWSet
- func (s *LWWSet[T]) Add(key string, value T) error
- func (s *LWWSet[T]) Exists(key string) bool
- func (s *LWWSet[T]) Get(key string) (T, bool)
- func (s *LWWSet[T]) GetAdditions() CrdtEngine[T]
- func (s *LWWSet[T]) GetAll() (map[string]T, error)
- func (s *LWWSet[T]) GetRemovals() CrdtEngine[T]
- func (s *LWWSet[T]) Merge(other LastWriterWinsSet[T]) error
- func (s *LWWSet[T]) Remove(key string, value T) error
- type LastWriterWinsSet
- type TimeMap
- func (s *TimeMap[T]) Add(key string, value T) error
- func (s *TimeMap[T]) AddWithTime(key string, value T, t time.Time) error
- func (s *TimeMap[T]) AddedAt(key string) (time.Time, bool)
- func (s *TimeMap[T]) Each(f func(key string, val T, addedAt time.Time) error) error
- func (s *TimeMap[T]) Get(key string) (T, bool)
- func (s *TimeMap[T]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CrdtEngine ¶
type LWWSet ¶
type LWWSet[T any] struct { Additions CrdtEngine[T] `json:"additions"` Removals CrdtEngine[T] `json:"removals"` }
LWWSet is a Last-Writer-Wins Set implementation
func (*LWWSet[T]) GetAdditions ¶
func (s *LWWSet[T]) GetAdditions() CrdtEngine[T]
func (*LWWSet[T]) GetRemovals ¶
func (s *LWWSet[T]) GetRemovals() CrdtEngine[T]
func (*LWWSet[T]) Merge ¶
func (s *LWWSet[T]) Merge(other LastWriterWinsSet[T]) error
Merge additions and removals from other LWWSet into current set
type LastWriterWinsSet ¶
type LastWriterWinsSet[T any] interface { Add(string, T) error Remove(string, T) error Exists(string) bool Get(string) (T, bool) GetAll() (map[string]T, error) Merge(LastWriterWinsSet[T]) error GetAdditions() CrdtEngine[T] GetRemovals() CrdtEngine[T] }
func NewLWWSet ¶
func NewLWWSet[T comparable](addition, removal CrdtEngine[T]) LastWriterWinsSet[T]
NewLWWSet returns an implementation of a LastWriterWinsSet
type TimeMap ¶
type TimeMap[T any] struct { Storage map[string]Element[T] `json:"elements"` // contains filtered or unexported fields }
TimeMap is an implementation of a timeSet that uses a map data structure. We map items to timestamps.
func NewTimeSet ¶
func NewTimeSet[T comparable]() *TimeMap[T]
newTimeSet returns an empty map-backed implementation of the CrdtEngine interface
func (*TimeMap[T]) Add ¶
Add an element in the set if one of the following condition is met: - Given element does not exist yet - Given element already exists but with a lesser timestamp than the given one
func (*TimeMap[T]) AddWithTime ¶
Add an element in the set if one of the following condition is met: - Given element does not exist yet - Given element already exists but with a lesser timestamp than the given one
func (*TimeMap[T]) AddedAt ¶
AddedAt returns the timestamp of a given element if it exists
The second return value (bool) indicates whether the element exists or not If the given element does not exist, the second return (bool) is false