ExRingRing.Application.Services.HashRingService (ExRingRing v0.1.1)

Copy Markdown View Source

Application service for hash ring operations.

This is the main entry point for the application layer.

Summary

Functions

Adds a single node to the ring.

Adds nodes to the ring.

Collects N nodes for an item (for replication).

Creates a new hash ring.

Creates a new hash ring from keys.

Checks if ring is empty.

Finds the node responsible for an item.

Gets the node count.

Gets all nodes in the ring.

Removes a single node from the ring.

Removes nodes from the ring.

Functions

add_node(ring, node)

Adds a single node to the ring.

add_nodes(ring, nodes)

Adds nodes to the ring.

collect_nodes(ring, item, count)

Collects N nodes for an item (for replication).

create_ring(nodes, opts \\ [])

Creates a new hash ring.

create_ring_from_keys(keys, opts \\ [])

@spec create_ring_from_keys(
  [atom() | binary() | integer()],
  keyword()
) :: ExRingRing.Domain.Entities.Ring.t()

Creates a new hash ring from keys.

empty?(ring)

Checks if ring is empty.

find_node(ring, item)

@spec find_node(ExRingRing.Domain.Entities.Ring.t(), term()) ::
  {:ok, ExRingRing.Domain.Entities.Node.t()} | :error

Finds the node responsible for an item.

get_node_count(ring)

@spec get_node_count(ExRingRing.Domain.Entities.Ring.t()) :: non_neg_integer()

Gets the node count.

get_nodes(ring)

Gets all nodes in the ring.

remove_node(ring, key)

Removes a single node from the ring.

remove_nodes(ring, keys)

Removes nodes from the ring.