Package versionvector

import "github.com/byte-mug/golibs/versionvector"

Overview

An implementation of the Version vector technique for distributed systems.

Basics

A Version vector is a set of key value pairs, where the key IDENTIFIES the Node modifying the data item, and the value is the version. If a key value-pair with a given key does not exist, 0 is the default value.

Requirements

Two Nodes MUST NOT have the same key and the key SHOULD NOT change over the lifetime of the Node.

Caveats

The algorithm is capable to detect Conflicts but it is not capable to resolve conflicts that occured.

Index

type Comparison

type Comparison uint

-

func GetComparison

func GetComparison(lower, higher bool) Comparison

-

func (Comparison) AsInt

func (c Comparison) AsInt() int

-

func (Comparison) Conflict

func (c Comparison) Conflict() bool

-

func (Comparison) Higher

func (c Comparison) Higher() bool

-

func (Comparison) Lower

func (c Comparison) Lower() bool

-

func (Comparison) String

func (c Comparison) String() string

-

type IntVector

	type IntVector []uint64
 A Version vector with integers as node-IDs.

func (IntVector) Compare

func (v IntVector) Compare(other IntVector) Comparison

-

func (IntVector) Increment

	func (v IntVector) Increment(node uint64) IntVector
 Increments the node's version and returns the new vector.

type Vector

	type Vector map[string]uint64
 A Version vector with strings as node-IDs.

func (Vector) Clone

func (v Vector) Clone() Vector

-

func (Vector) Compare

func (v Vector) Compare(other Vector) Comparison

-

func (Vector) Increment

func (v Vector) Increment(node string)

-