brazier/presence/clock
Vector clocks for presence replication, ported from Phoenix.Tracker.Clock.
A clock maps each replica to the highest clock value seen from it.
A clockset is a list of
#(replica, clock) pairs that no member dominates: the set of peers
whose state this replica has not yet caught up with.
Types
Values
pub fn append_clock(
clockset: List(#(n, dict.Dict(r, Int))),
entry: #(n, dict.Dict(r, Int)),
) -> List(#(n, dict.Dict(r, Int)))
Add a replica’s clock to a clockset, keeping only clocks no other
member dominates. Phoenix: append_clock/2.
pub fn clockset_replicas(
clockset: List(#(n, dict.Dict(r, Int))),
) -> set.Set(n)
The replicas named in a clockset.
pub fn dominates(
c1: dict.Dict(r, Int),
c2: dict.Dict(r, Int),
) -> Bool
Whether c1 names every replica of c2 with at least its value.
Phoenix: dominates?/2.
pub fn dominates_or_equal(
c1: dict.Dict(r, Int),
c2: dict.Dict(r, Int),
) -> Bool
Whether every entry of c1 is at least the matching entry of c2.
An empty c1 only dominates-or-equals another empty clock.
Phoenix: dominates_or_equal?/2.
pub fn filter_replicas(
clock: dict.Dict(r, Int),
replicas: List(r),
) -> dict.Dict(r, Int)
The clock restricted to replicas.
pub fn lowerbound(
c1: dict.Dict(r, Int),
c2: dict.Dict(r, Int),
) -> dict.Dict(r, Int)
The entrywise minimum of two clocks.