ExHashRing.Node (ex_hash_ring v6.0.4) View Source

Types and Functions for working with Ring Nodes and their Replicas

Link to this section Summary

Types

Nodes can be defined by either using a bare name or using a fully specified node. When using a bare name the definition will have to be converted into a fully specified node, see normalize/2.

Nodes are uniquely identified in the ring by their name.

Replicas is a count of how many times a Node should be placed into a Ring.

t()

Nodes are properly specified as a tuple of their name and their number of replicas

Nodes are expanded into multiple virtual nodes.

Functions

Expands a list of nodes into a list of virtual nodes.

Converts definitions into fully specified nodes.

Link to this section Types

Specs

definition() :: name() | t()

Nodes can be defined by either using a bare name or using a fully specified node. When using a bare name the definition will have to be converted into a fully specified node, see normalize/2.

Specs

name() :: binary()

Nodes are uniquely identified in the ring by their name.

Specs

replicas() :: non_neg_integer()

Replicas is a count of how many times a Node should be placed into a Ring.

Negative replica counts will result in an ArgumentError when expanded

Specs

t() :: {name(), replicas()}

Nodes are properly specified as a tuple of their name and their number of replicas

Specs

virtual() :: {ExHashRing.Hash.t(), name()}

Nodes are expanded into multiple virtual nodes.

Link to this section Functions

Specs

expand([t()]) :: [virtual()]

Expands a list of nodes into a list of virtual nodes.

Specs

expand([t()], replicas()) :: [virtual()]
Link to this function

normalize(nodes, replicas)

View Source

Specs

normalize([definition()], replicas()) :: [t()]
normalize(t(), replicas()) :: t()
normalize(name(), replicas()) :: t()

Converts definitions into fully specified nodes.

A single definition or a list of defintions can be normalized by this function.