Search documentation of macula

# macula_node (macula v4.4.1)

View Source

Node identity and metadata management. Represents a single node in the Macula mesh.

# Summary

## Types

address/0
macula_node/0
metadata/0
node_id/0

32-byte unique identifier

realm/0

## Functions

equals(Node1, Node2)

Check if two nodes are equal (by ID).

from_binary(Binary)

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

get_address(Node)

Get address.

get_id(_)

Get node ID.

get_metadata(Node)

Get metadata.

get_realm(_)

Get realm.

new(Realm)

Create new node with random ID.

new(Realm, Metadata)

Create new node with random ID and metadata.

set_address(Node, Address)

Set address.

set_metadata(Node, Metadata)

Set metadata (replaces existing).

to_binary(Node)

Encode node to binary.

update_metadata(Node, NewMetadata)

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).