macula_node (macula v0.14.3)

View Source

Node 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 metadata (replaces existing).

Encode node to binary.

Update metadata (merges with existing).

Types

address/0

-type address() :: {inet:ip_address(), inet:port_number()}.

macula_node/0

-type macula_node() ::
          #{node_id := node_id(), realm := realm(), metadata => metadata(), address => address()}.

metadata/0

-type metadata() :: map().

node_id/0

-type node_id() :: binary().

32-byte unique identifier

realm/0

-type realm() :: binary().

Functions

equals(Node1, Node2)

-spec equals(macula_node(), macula_node()) -> boolean().

Check if two nodes are equal (by ID).

from_binary(Binary)

-spec from_binary(binary()) -> macula_node().

Decode node from binary. Crashes on invalid binary or structure - exposes bugs in encoding/decoding logic.

get_address(Node)

-spec get_address(macula_node()) -> address() | undefined.

Get address.

get_id(_)

-spec get_id(macula_node()) -> node_id().

Get node ID.

get_metadata(Node)

-spec get_metadata(macula_node()) -> metadata().

Get metadata.

get_realm(_)

-spec get_realm(macula_node()) -> realm().

Get realm.

new(Realm)

-spec new(realm()) -> macula_node().

Create new node with random ID.

new(Realm, Metadata)

-spec new(realm(), metadata()) -> macula_node().

Create new node with random ID and metadata.

set_address(Node, Address)

-spec set_address(macula_node(), address()) -> macula_node().

Set address.

set_metadata(Node, Metadata)

-spec set_metadata(macula_node(), metadata()) -> macula_node().

Set metadata (replaces existing).

to_binary(Node)

-spec to_binary(macula_node()) -> binary().

Encode node to binary.

update_metadata(Node, NewMetadata)

-spec update_metadata(macula_node(), metadata()) -> macula_node().

Update metadata (merges with existing).