Static hash ring implementation using sorted array (tuple).
Optimized for read-heavy workloads. Adding/removing nodes requires O(N log N) time but finding nodes is a guaranteed O(log N) lower-bound binary search.
Summary
Functions
Adds nodes to the ring.
Folds over nodes starting from item's position.
Gets all nodes.
Gets non-phantom node count.
Hashes an item.
Creates a new static hash ring.
Removes nodes from the ring.
Types
@type state() :: %{ vnodes: tuple(), base: ExRingRing.Infrastructure.HashRing.Base.state() }
Functions
@spec add_nodes([ExRingRing.Domain.Entities.Node.t()], state()) :: state()
Adds nodes to the ring.
Folds over nodes starting from item's position.
@spec get_nodes(state()) :: %{required(term()) => ExRingRing.Domain.Entities.Node.t()}
Gets all nodes.
@spec get_non_phantom_node_count(state()) :: non_neg_integer()
Gets non-phantom node count.
@spec hash(term(), state()) :: non_neg_integer()
Hashes an item.
@spec make( [ExRingRing.Domain.Entities.Node.t()], ExRingRing.Domain.ValueObjects.HashConfig.t() ) :: state()
Creates a new static hash ring.
Removes nodes from the ring.