vector_clock v0.1.0 VectorClock
Elixir implementation of vector clocks.
About
Vector clocks are used in distributed systems as a way of maintaining a logical ordering of events. A vector clock consists of a list of dots, which each dot representing a node in a distributed system. A dot consists of an identifier for the node, it’s current count, and a timestamp from the last time it was incremented. When a node sends an event to another node it increments the it’s dot in it’s vector clock and sends the clock along side the message. A node receiving a message can determine whether it has seen the effect of that message already by comparing it’s vector clock with the received vector clock.
Source
Based on the erlang version from
:riak_core
.
Summary
Functions
Get all nodes in the vector clock
Check if vector clock va
is a descendent of vector clock vb
Check whether a vector clock decends from a given dot
Checks if vector clock va
strictly dominates vector clock vb
Compares vector clocks for equality
Create a new empty vector clock
Create a new vectory clock with an initial dot
Get the counter value from a vector clock for a specific node
Get the dot entry from a vector clock for a specific node
Get the timestamp value from a vector clock for a specific node
Increment the vector clock at node
Increment the vector clock at node
Combines a list of vector clocks into their least possible common descendant
Prunes a vector clock based on various parameters
Converts a dot to a pure dot, for when timestamp data is not needed
Current timestamp for a vector clock
Checks if the given argument is a valid dot
Types
Functions
Get all nodes in the vector clock.
Check if vector clock va
is a descendent of vector clock vb
.
Check whether a vector clock decends from a given dot.
Checks if vector clock va
strictly dominates vector clock vb
.
A vector clock is said to dominate another when it’s clock represents a later logical time than the other.
Create a new empty vector clock.
Create a new vectory clock with an initial dot.
Get the counter value from a vector clock for a specific node.
Get the dot entry from a vector clock for a specific node.
Get the timestamp value from a vector clock for a specific node.
Increment the vector clock at node.
Increment the vector clock at node.
Combines a list of vector clocks into their least possible common descendant.
Prunes a vector clock based on various parameters.
Vector clocks get pruned when they are either considered too large or when the top-most dot is too old. Entries are removed one-by-one off the top until neither of the two conditions are met.
Options
:small_vclock
- max size for a vector clock to be not pruned.:young_vclock
- max difference betweennow
and the timestamp on the latest dot for a vector clock to not be pruned.:big_vclock
- vector clocks larger than this will be pruned.:old_vclock
- max difference betweennow
and the timestamp on the latest dot for it to get pruned.
Converts a dot to a pure dot, for when timestamp data is not needed.
Current timestamp for a vector clock.