Documentation ¶
Index ¶
- type Condition
- type VClock
- func (vc VClock) Bytes() []byte
- func (vc VClock) Compare(other VClock, cond Condition) bool
- func (vc VClock) CompareOld(other VClock, cond Condition) bool
- func (vc VClock) Copy() VClock
- func (vc VClock) CopyFromMap(otherMap map[string]uint64) VClock
- func (vc VClock) FindTicks(id string) (uint64, bool)
- func (vc VClock) GetMap() map[string]uint64
- func (vc VClock) LastUpdate() (last uint64)
- func (vc VClock) Merge(other VClock)
- func (vc VClock) Order(other VClock) Condition
- func (vc VClock) PrintVC()
- func (vc VClock) ReturnVCString() string
- func (vc VClock) Set(id string, ticks uint64)
- func (vc VClock) Tick(id string)
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.
type VClock ¶
Vector clocks are maps of string to uint64 where the string is the id of the process, and the uint64 is the clock value
func (VClock) Compare ¶
Compare takes another clock ("other") and determines if it is Equal, an Ancestor, Descendant, or Concurrent with the callees ("vc") clock. The condition is specified by the cond parameter, which may be ORed. For example, to check if two clocks are concurrent or descendants, you would call Compare(other, Concurrent|Descendant). If the condition is met, true is returned, otherwise false is returned.
func (VClock) CompareOld ¶
CompareOld takes another clock and determines if it is Equal, an Ancestor, Descendant, or Concurrent with the callees clock. Deprecated This is the original implementation of Compare, which is now deprecated. It is left here for reference.
func (VClock) CopyFromMap ¶
CopyFromMap copys a map to a vector clock
func (VClock) FindTicks ¶
FindTicks returns the clock value for a given id, if a value is not found false is returned
func (VClock) LastUpdate ¶
LastUpdate returns the clock value of the oldest clock
func (VClock) Merge ¶
Merge takes the max of all clock values in other and updates the values of the callee
func (VClock) Order ¶
Order determines the relationship between two clocks. It returns Ancestor if the callee is an ancestor of the other clock, Descendant if the callee is a descendant of the other clock, Equal if the clocks are equal, and Concurrent if the clocks are concurrent. Two important notes about this implementation: 1. The return value is a constant, it is not ORed together. This means that if you want to compare the output, you can use the == operator. Note that we recommend using the Compare method instead. 2. If the clocks are equal, the return value is Equal. This is different from the original vector clock implementation, which returned Concurrent AND Equal.
This code is adapted from the Voldemort implementation of vector clocks: https://github.com/voldemort/voldemort/blob/master/src/java/voldemort/versioning/VectorClockUtils.java The original code is licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 Copyright 2008-2013 LinkedIn, Inc.
func (VClock) PrintVC ¶
func (vc VClock) PrintVC()
PrintVC prints the callees vector clock to stdout
func (VClock) ReturnVCString ¶
ReturnVCString returns a string encoding of a vector clock