Search documentation of macula

# macula_relay_handler (macula v0.44.2)

View Source

Relay handler — one process per connected node.

Manages a single QUIC stream to a node. Routes messages using: - pg groups for pub/sub (subscribe = join, publish = broadcast) - gproc for RPC (register = reg, call = lookup + forward)

Cross-relay routing uses dual pg groups per topic: - `{relay_topic, Topic}` — ALL handlers (client + peer) join. Used for local PUBLISH broadcasting. Peer handlers forward messages to their remote relay. - `{relay_local, Topic}` — only CLIENT handlers join. Used for cross-relay delivery (loop-safe). When a message arrives from a peer relay, it is delivered ONLY to local client handlers via this group.

Peer vs client is determined by the CONNECT handshake: peers send `type => <<"relay">>`. This prevents pub/sub loops where a message would bounce between relays indefinitely.

When this process dies (node disconnects), pg and gproc automatically remove all subscriptions and procedure registrations.

# Summary

## Functions

handle_call(Request, From, State)
handle_cast(Msg, State)
handle_info(Info, State)
init(_)
start_link(Conn, Stream)
terminate(Reason, State)

# Functions

# handle_call(Request, From, State)

# handle_cast(Msg, State)

# handle_info(Info, State)

# init(_)

# start_link(Conn, Stream)

    -spec start_link(reference(), reference()) -> {ok, pid()} | {error, term()}.

# terminate(Reason, State)