Base module for hash ring implementations.
Contains shared logic for hash calculation, virtual node management, and node state.
Summary
Functions
Adds a node to base state.
Calculates virtual node count for a node.
Creates virtual nodes for a node.
Gets hash mask.
Gets all nodes.
Gets non-phantom node count.
Calculates hash for a term.
Creates base state from hash config.
Removes a node from base state.
Types
@type state() :: %{ nodes: %{required(term()) => ExRingRing.Domain.Entities.Node.t()}, phantom_count: non_neg_integer(), virtual_node_count: pos_integer(), hash_mask: non_neg_integer(), hash_algorithm: atom() }
Functions
@spec add_node(ExRingRing.Domain.Entities.Node.t(), state()) :: state()
Adds a node to base state.
@spec calc_virtual_node_count(ExRingRing.Domain.Entities.Node.t(), state()) :: non_neg_integer()
Calculates virtual node count for a node.
@spec create_virtual_nodes( ExRingRing.Domain.Entities.Node.t(), non_neg_integer(), non_neg_integer(), state() ) :: [ExRingRing.Domain.ValueObjects.VirtualNode.t()]
Creates virtual nodes for a node.
@spec get_hash_mask(state()) :: non_neg_integer()
Gets hash mask.
@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()
Calculates hash for a term.
@spec make_base_state(ExRingRing.Domain.ValueObjects.HashConfig.t()) :: state()
Creates base state from hash config.
Removes a node from base state.