macula (macula v1.4.23)
View SourceMacula SDK — Public API for mesh applications.
This is the main entry point for applications using the Macula SDK. All functions delegate to macula_mesh_client or macula_multi_relay for relay mesh communication.
Summary
Functions
Advertise an RPC procedure handler.
Advertise with options.
Call a remote procedure (default 5s timeout).
Call a remote procedure with timeout.
Call a remote procedure on a specific target node (default 5s timeout).
Call a remote procedure on a specific target node with timeout.
Connect to a Macula relay.
Disconnect from the relay.
Ensure this node is running in distributed mode.
Get the Erlang cluster cookie.
Join the Macula relay mesh with Erlang distribution.
List all nodes connected to the relay (default 5s timeout).
List all nodes connected to the relay with options.
Subscribe to node up/down events.
Publish an event to a topic (fire-and-forget).
Publish an event with options.
Resolve a mesh name to node identity information.
Set the Erlang cluster cookie.
Subscribe to a topic.
Stop advertising a procedure.
Unsubscribe from node up/down events.
Unsubscribe from a topic.
Types
Functions
Advertise an RPC procedure handler.
Advertise with options.
Call a remote procedure (default 5s timeout).
Call a remote procedure with timeout.
Call a remote procedure on a specific target node (default 5s timeout).
Target can be a mesh name, site_id, or node_id (all binaries). The relay resolves the target and routes the CALL directly to that node.
-spec call_node(client(), binary(), procedure(), term(), pos_integer()) -> {ok, term()} | {error, term()}.
Call a remote procedure on a specific target node with timeout.
Connect to a Macula relay.
Returns a client PID (macula_mesh_client gen_server) that you pass to all other API functions. Accepts a single URL binary or a list.
-spec disconnect(client()) -> ok.
Disconnect from the relay.
-spec ensure_distributed() -> ok | {error, term()}.
Ensure this node is running in distributed mode.
-spec get_cookie() -> atom().
Get the Erlang cluster cookie.
Join the Macula relay mesh with Erlang distribution.
After calling this, standard OTP distribution works across firewalls. Options: relays (required list), realm, identity, site, tls_verify.
List all nodes connected to the relay (default 5s timeout).
List all nodes connected to the relay with options.
-spec monitor_nodes() -> ok.
Subscribe to node up/down events.
Publish an event to a topic (fire-and-forget).
Publish an event with options.
Resolve a mesh name to node identity information.
Returns the node's identity including name, site_id, city, endpoint, and connected_at timestamp. Works for names, site_ids, or node_ids.
Set the Erlang cluster cookie.
-spec subscribe(client(), topic(), fun((term()) -> ok) | pid()) -> {ok, reference()} | {error, term()}.
Subscribe to a topic.
The callback receives the event payload (map or binary). Returns a subscription reference for unsubscribing.
Stop advertising a procedure.
-spec unmonitor_nodes() -> ok.
Unsubscribe from node up/down events.
Unsubscribe from a topic.