herd v0.4.2 Herd.Router behaviour View Source

Manages load balancing between nodes in the cluster, for example through a hash ring

Link to this section Summary

Callbacks

Add nodes to the router

Gets a node from the router using the given key

Gets nodes mapped by the given keys

Initialize a new load router

Return all nodes in the router

Remove nodes from the router

Link to this section Types

Link to this type herd_node() View Source
herd_node() :: term()

Link to this section Callbacks

Link to this callback add_nodes(lb, nodes) View Source
add_nodes(lb :: router(), nodes :: [herd_node()]) :: router()

Add nodes to the router

Link to this callback get_node(lb, key) View Source
get_node(lb :: router(), key :: term()) :: {:ok, herd_node()} | {:error, any()}

Gets a node from the router using the given key

Link to this callback get_nodes(lb, keys) View Source
get_nodes(lb :: router(), keys :: [term()]) ::
  {:ok, %{optional(term()) => herd_node()}} | {:error, any()}

Gets nodes mapped by the given keys

Initialize a new load router

Return all nodes in the router

Link to this callback remove_nodes(lb, nodes) View Source
remove_nodes(lb :: router(), nodes :: [herd_node()]) :: router()

Remove nodes from the router