vclock

package
v0.0.0-...-ae07272 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition int

Condition constants define how to compare a vector clock against another, and may be ORed together when being provided to the Compare method.

const (
	Equal Condition = 1 << iota
	Ancestor
	Descendant
	Concurrent
)

Constants define comparison conditions between pairs of vector clocks

type VClock

type VClock map[string]uint64

VClock are maps of string to uint64 where the string is the id of the process, and the uint64 is the clock value

func FromBytes

func FromBytes(data []byte) (vc VClock, err error)

FromBytes decodes a vector clock

func New

func New() VClock

New returns a new vector clock

func (VClock) Bytes

func (vc VClock) Bytes() []byte

Bytes returns an encoded vector clock

func (VClock) Compare

func (vc VClock) Compare(other VClock, cond Condition) bool

Compare takes another clock and determines if it is Equal, Ancestor, Descendant, or Concurrent with the callee's clock.

func (VClock) Copy

func (vc VClock) Copy() VClock

Copy returns a copy of the clock

func (VClock) CopyFromMap

func (vc VClock) CopyFromMap(otherMap map[string]uint64) VClock

CopyFromMap copies a map to a vector clock

func (VClock) FindTicks

func (vc VClock) FindTicks(id string) (uint64, bool)

FindTicks returns the clock value for a given id, if a value is not found false is returned

func (VClock) GetMap

func (vc VClock) GetMap() map[string]uint64

GetMap returns the map typed vector clock

func (VClock) LastUpdate

func (vc VClock) LastUpdate() (last uint64)

LastUpdate returns the clock value of the oldest clock

func (VClock) Merge

func (vc VClock) Merge(other VClock)

Merge takes the max of all clock values in other and updates the values of the callee

func (VClock) PrintVC

func (vc VClock) PrintVC()

PrintVC prints the callee's vector clock to stdout

func (VClock) ReturnVCString

func (vc VClock) ReturnVCString() string

ReturnVCString returns a string encoding of a vector clock

func (VClock) Set

func (vc VClock) Set(id string, ticks uint64)

Set assigns a clock value to a clock index

func (VClock) Tick

func (vc VClock) Tick(id string)

Tick has replaced the old update

Jump to

Keyboard shortcuts

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