Grove.Mergeable protocol (Grove v0.1.1)

View Source

Protocol for merging CRDT states.

Allows polymorphic merging of any CRDT type without knowing the concrete implementation at compile time.

Example

iex> Grove.Mergeable.merge(counter1, counter2)
%Grove.Counter.GCounter{...}

Summary

Types

t()

All the types that implement this protocol.

Functions

Merges two CRDT states into one.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

merge(left, right)

@spec merge(t(), t()) :: t()

Merges two CRDT states into one.

The merge operation must satisfy:

  • Commutativity: merge(a, b) == merge(b, a)
  • Associativity: merge(merge(a, b), c) == merge(a, merge(b, c))
  • Idempotence: merge(a, a) == a