NodeActivator.Util (NodeActivator v1.1.0)

View Source

Utility functions for NodeActivator, providing helper functions for node management and name generation in distributed Erlang systems.

Summary

Functions

Generates a unique node name by combining a prefix with a random string and the hostname.

Functions

generate_node_name(prefix)

@spec generate_node_name(binary()) :: {:ok, atom()} | {:error, binary()}

Generates a unique node name by combining a prefix with a random string and the hostname.

Parameters

  • prefix - A binary string that will be used as the prefix for the node name. Spaces in the prefix will be replaced with hyphens.

Returns

  • {:ok, atom()} - A tuple containing the generated node name as an atom.
  • {:error, binary()} - A tuple containing an error message if the hostname cannot be determined.

Examples

iex> {:ok, node_name} = NodeActivator.Util.generate_node_name("test")
iex> is_atom(node_name)
true
iex> Atom.to_string(node_name) =~ ~r/test_[a-z2-7]+@.+/
true