macula_node (macula v0.14.3)
View SourceNode identity and metadata management. Represents a single node in the Macula mesh.
Summary
Functions
Check if two nodes are equal (by ID).
Decode node from binary. Crashes on invalid binary or structure - exposes bugs in encoding/decoding logic.
Get address.
Get node ID.
Get metadata.
Get realm.
Create new node with random ID.
Create new node with random ID and metadata.
Set address.
Set metadata (replaces existing).
Encode node to binary.
Update metadata (merges with existing).
Types
-type address() :: {inet:ip_address(), inet:port_number()}.
-type metadata() :: map().
-type node_id() :: binary().
32-byte unique identifier
-type realm() :: binary().
Functions
-spec equals(macula_node(), macula_node()) -> boolean().
Check if two nodes are equal (by ID).
-spec from_binary(binary()) -> macula_node().
Decode node from binary. Crashes on invalid binary or structure - exposes bugs in encoding/decoding logic.
-spec get_address(macula_node()) -> address() | undefined.
Get address.
-spec get_id(macula_node()) -> node_id().
Get node ID.
-spec get_metadata(macula_node()) -> metadata().
Get metadata.
-spec get_realm(macula_node()) -> realm().
Get realm.
-spec new(realm()) -> macula_node().
Create new node with random ID.
-spec new(realm(), metadata()) -> macula_node().
Create new node with random ID and metadata.
-spec set_address(macula_node(), address()) -> macula_node().
Set address.
-spec set_metadata(macula_node(), metadata()) -> macula_node().
Set metadata (replaces existing).
-spec to_binary(macula_node()) -> binary().
Encode node to binary.
-spec update_metadata(macula_node(), metadata()) -> macula_node().
Update metadata (merges with existing).