ExRingRing. Infrastructure. HashRing. Dynamic
(ex_ring_ring v0.1.0)
Copy Markdown
Dynamic hash ring implementation using balanced tree (gb_trees).
Optimized for write-heavy workloads. Adding/removing nodes is O(log N) but finding nodes is slightly slower than static implementation.
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 dynamic hash ring.
Removes nodes from the ring.
Types
@type state() :: %{ vnodes: :gb_trees.tree(), 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 dynamic hash ring.
Removes nodes from the ring.