ExHashRing.Node (ex_hash_ring v7.0.0)

View Source

Types and Functions for working with Ring Nodes and their Replicas

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.

Types

definition()

@type 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.

name()

@type name() :: binary()

Nodes are uniquely identified in the ring by their name.

replicas()

@type 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

t()

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

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

virtual()

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

Nodes are expanded into multiple virtual nodes.

Functions

expand(nodes)

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

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

expand(nodes, replicas)

@spec expand([t()], replicas()) :: [virtual()]

normalize(nodes, replicas)

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

Converts definitions into fully specified nodes.

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