ExRingRing.Domain.ValueObjects.VirtualNode (ExRingRing v0.1.1)

Copy Markdown View Source

Value object representing a virtual node in the hash ring.

A virtual node has a hash value, sequence number, and references a physical node.

Summary

Functions

Compares two virtual nodes by hash, then sequence.

Gets the virtual node hash.

Gets the physical node.

Gets the node key from the physical node.

Gets the virtual node sequence.

Checks if virtual node a is greater than b.

Checks if virtual node a is less than b.

Creates a new virtual node.

Types

t()

@type t() :: %ExRingRing.Domain.ValueObjects.VirtualNode{
  hash: non_neg_integer(),
  node: ExRingRing.Domain.Entities.Node.t(),
  sequence: non_neg_integer()
}

Functions

compare(a, b)

@spec compare(t(), t()) :: :lt | :eq | :gt

Compares two virtual nodes by hash, then sequence.

get_hash(virtual_node)

@spec get_hash(t()) :: non_neg_integer()

Gets the virtual node hash.

get_node(virtual_node)

@spec get_node(t()) :: ExRingRing.Domain.Entities.Node.t()

Gets the physical node.

get_node_key(virtual_node)

@spec get_node_key(t()) :: term()

Gets the node key from the physical node.

get_sequence(virtual_node)

@spec get_sequence(t()) :: non_neg_integer()

Gets the virtual node sequence.

greater_than(a, b)

@spec greater_than(t(), t()) :: boolean()

Checks if virtual node a is greater than b.

less_than(a, b)

@spec less_than(t(), t()) :: boolean()

Checks if virtual node a is less than b.

new(hash, sequence, node)

Creates a new virtual node.