crdt

package
v0.0.0-...-ec24cc8 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ILastWriterWinsGraph

type ILastWriterWinsGraph[T comparable] interface {
	AddVertex(T) error
	Vertices() ([]T, error)
	DeleteVertex(T) error
	HasVertex(T) bool
	AddEdge(v1, v2 T) error
	DeleteEdge(v1, v2 T) error
	HasEdge(v1, v2 T) bool
	VertexEdges(v T) ([]T, error)
	FindPath(v1, v2 T) ([]T, error)
	Merge(ILastWriterWinsGraph[T]) error
	// contains filtered or unexported methods
}

func NewLastWriterWinsGraph

func NewLastWriterWinsGraph[T comparable]() ILastWriterWinsGraph[T]

type ILastWriterWinsSet

type ILastWriterWinsSet[T comparable] interface {
	Add(T, time.Time) error
	Remove(T, time.Time) error
	Has(T) bool
	Get() ([]T, error)
	Merge(ILastWriterWinsSet[T]) error
	Added() ITimeSet[T]
	Deleted() ITimeSet[T]
}

func NewLastWriterWinsSet

func NewLastWriterWinsSet[T comparable]() ILastWriterWinsSet[T]

type ITimeSet

type ITimeSet[T comparable] interface {
	Store(T, time.Time) error
	When(T) (time.Time, bool)
	Each(func(T, time.Time) error) error
	Size() int
}

func NewTimeSet

func NewTimeSet[T comparable]() ITimeSet[T]

type LastWriterWinsGraph

type LastWriterWinsGraph[T comparable] struct {
	// contains filtered or unexported fields
}

LastWriterWinsGraph is a structure for a graph with vertices and edges based on LWW sets

func (*LastWriterWinsGraph[T]) AddEdge

func (g *LastWriterWinsGraph[T]) AddEdge(vertex1, vertex2 T) error

func (*LastWriterWinsGraph[T]) AddVertex

func (g *LastWriterWinsGraph[T]) AddVertex(vertex T) error

func (*LastWriterWinsGraph[T]) DeleteEdge

func (g *LastWriterWinsGraph[T]) DeleteEdge(vertex1, vertex2 T) error

func (*LastWriterWinsGraph[T]) DeleteVertex

func (g *LastWriterWinsGraph[T]) DeleteVertex(vertex T) error

func (*LastWriterWinsGraph[T]) FindPath

func (g *LastWriterWinsGraph[T]) FindPath(vertex1, vertex2 T) ([]T, error)

func (*LastWriterWinsGraph[T]) HasEdge

func (g *LastWriterWinsGraph[T]) HasEdge(vertex1, vertex2 T) bool

func (*LastWriterWinsGraph[T]) HasVertex

func (g *LastWriterWinsGraph[T]) HasVertex(vertex T) bool

func (*LastWriterWinsGraph[T]) Merge

func (g *LastWriterWinsGraph[T]) Merge(other ILastWriterWinsGraph[T]) error

func (*LastWriterWinsGraph[T]) VertexEdges

func (g *LastWriterWinsGraph[T]) VertexEdges(vertex T) ([]T, error)

func (*LastWriterWinsGraph[T]) Vertices

func (g *LastWriterWinsGraph[T]) Vertices() ([]T, error)

type LastWriterWinsSet

type LastWriterWinsSet[T comparable] struct {
	// contains filtered or unexported fields
}

func (*LastWriterWinsSet[T]) Add

func (s *LastWriterWinsSet[T]) Add(value T, t time.Time) error

func (*LastWriterWinsSet[T]) Added

func (s *LastWriterWinsSet[T]) Added() ITimeSet[T]

func (*LastWriterWinsSet[T]) Deleted

func (s *LastWriterWinsSet[T]) Deleted() ITimeSet[T]

func (*LastWriterWinsSet[T]) Get

func (s *LastWriterWinsSet[T]) Get() ([]T, error)

Get returns set content

func (*LastWriterWinsSet[T]) Has

func (s *LastWriterWinsSet[T]) Has(value T) bool

func (*LastWriterWinsSet[T]) Merge

func (s *LastWriterWinsSet[T]) Merge(other ILastWriterWinsSet[T]) error

Merge additions and deletions from other LastWriterWinsSet into current set

func (*LastWriterWinsSet[T]) Remove

func (s *LastWriterWinsSet[T]) Remove(value T, t time.Time) error

type TimeSet

type TimeSet[T comparable] struct {
	Records map[T]time.Time `json:"records"`
	// contains filtered or unexported fields
}

func (*TimeSet[T]) Each

func (s *TimeSet[T]) Each(fn func(el T, when time.Time) error) error

func (*TimeSet[T]) Size

func (s *TimeSet[T]) Size() int

func (*TimeSet[T]) Store

func (s *TimeSet[T]) Store(value T, t time.Time) error

Store an element in the set if one of the following condition is met: we haven't encountered that element or the timestamp of the existing element is lesser than the fresh one

func (*TimeSet[T]) When

func (s *TimeSet[T]) When(value T) (time.Time, bool)

When returns the timestamp of a given element if it exists

Jump to

Keyboard shortcuts

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