alexandrepiveteau/elm-ordt/1.0.0

NOTE: the latest version is 2.1.2

ORDT.Weft

Wefts are like vector clocks - they offer causality information across different events in a distributed system. A new weft is empty. Each site is then associated with an index, indicating the index of the last operation received for that particular site.

For any two instances of Weft, an upper bound as well as a lower bound can be found. The lower bound is the last known state to both wefts. The upper bound is the minimal state that could know both wefts. This ability to find upper or/and a lower bound is often referred to as a semi-lattice.

Usually, these clocks are associated with some operations. There is, in general, no guarantee that a specific instance of weft is associated to a operation.

Types

type Weft comparable

Represents a weft in a distributed system. So Weft (Int) means that each site is identified by an Int, and Weft (String) that each site is identified by a String.

Primitives

empty : Weft comparable

Create a baseline that will always act as a proper lower bound for all the possible instances of an EchoWeft.

joinLower clock empty == empty


joinUpper clock empty == clock

Contents

getSiteIndex : comparable -> Weft comparable -> Maybe Int

Get the last operation index for a certain site.

insertSiteIndex : comparable -> Int -> Weft comparable -> Weft comparable

Set the last operation index for a certain site.

Semi-lattice

joinLower : Weft comparable -> Weft comparable -> Weft comparable

Perform a semi-lattice join on the lower bound of the two wefts.

joinUpper : Weft comparable -> Weft comparable -> Weft comparable

Perform a semi-lattice join on the upper bound of the two wefts.