View Source ProcessHub.Service.Ring (ProcessHub v0.2.0-alpha)

The Ring service provides API functions for managing the hash ring.

Summary

Functions

Adds a new node to the passed-in hash_ring and returns the new hash ring.

Creates a new hash ring instance from the given hub_nodes and returns the new hash ring.

Returns the hash ring instance belonging to the given hub_id.

Determines which node the given child_id belongs to.

Determines which nodes the given child_id belongs to.

Returns a list of all nodes in the hash ring.

Removes a node from the hash ring and returns the new hash ring.

Returns the storage key for the hash ring.

Functions

Link to this function

add_node(hash_ring, node)

View Source
@spec add_node(:hash_ring.t(), node()) :: :hash_ring.t()

Adds a new node to the passed-in hash_ring and returns the new hash ring.

@spec create_ring(any()) :: :hash_ring.ring(any(), any())

Creates a new hash ring instance from the given hub_nodes and returns the new hash ring.

@spec get_ring(ProcessHub.hub_id()) :: :hash_ring.t()

Returns the hash ring instance belonging to the given hub_id.

Link to this function

key_to_node(hash_ring, key, replication_factor)

View Source
@spec key_to_node(:hash_ring.t(), ProcessHub.child_id(), non_neg_integer()) :: node()
@spec key_to_node(:hash_ring.t(), ProcessHub.child_id(), non_neg_integer()) :: [
  node()
]

Determines which node the given child_id belongs to.

Link to this function

key_to_nodes(hash_ring, key, replication_factor)

View Source
@spec key_to_nodes(:hash_ring.t(), ProcessHub.child_id(), non_neg_integer()) :: [
  node()
]

Determines which nodes the given child_id belongs to.

The replication_factor determines how many nodes to return.

Returns a list of all nodes in the hash ring.

Link to this function

remove_node(hash_ring, node)

View Source
@spec remove_node(:hash_ring.t(), node()) :: :hash_ring.t()

Removes a node from the hash ring and returns the new hash ring.

@spec storage_key() :: :hash_ring_storage

Returns the storage key for the hash ring.