Value object representing hash ring configuration.
Summary
Functions
Calculates virtual node count for a node based on its weight, or for a raw base count and weight pair.
Gets the hash algorithm.
Gets the hash mask.
Gets the max hash byte size.
Gets the virtual node count.
Creates a new hash configuration.
Types
@type t() :: %ExRingRing.Domain.ValueObjects.HashConfig{ algorithm: atom(), hash_mask: non_neg_integer(), max_hash_byte_size: pos_integer(), virtual_node_count: pos_integer() }
Functions
@spec calc_virtual_node_count(t(), ExRingRing.Domain.Entities.Node.t()) :: non_neg_integer()
@spec calc_virtual_node_count(pos_integer(), number()) :: non_neg_integer()
Calculates virtual node count for a node based on its weight, or for a raw base count and weight pair.
Weight 0 (phantom node) yields 0 virtual nodes. Any positive weight yields
at least one virtual node so the node is always reachable on the ring, even
when the scaled count would round down to zero.
Gets the hash algorithm.
@spec get_hash_mask(t()) :: non_neg_integer()
Gets the hash mask.
@spec get_max_hash_byte_size(t()) :: pos_integer()
Gets the max hash byte size.
@spec get_virtual_node_count(t()) :: pos_integer()
Gets the virtual node count.
Creates a new hash configuration.
Accepts :hash_algorithm (canonical, matches the public API docs) and
:algorithm as an alias. Raises ArgumentError on invalid values.