Search documentation of macula

# macula_dist_bridge (macula v4.4.1)

View Source

Supervised bridge process for relay distribution tunnels.

Each tunnel gets one bridge gen_server that owns: - A BridgeSock (gen_tcp, raw byte pipe) - A reader process (linked, reads socket -> publishes to mesh pool) - A writer loop (handle_info, receives `macula_event` frames from the V2 pool and writes the decrypted payload to the socket) - Metrics counters for the tunnel - A V2 pool subscription (unsubscribed on terminate)

### Pool Reconnection

The V2 pool replays subscriptions on link respawn, so the bridge's incoming data resumes automatically. The reader handles publish failures by retrying — if the pool is temporarily wedged the publishes buffer in its gen_server mailbox and flush when at least one station_link inside the pool comes back online.

If the pool gen_server PID itself dies (process crash, not just an internal link drop), the bridge attempts to re-acquire a new pool from persistent_term and re-subscribe. If no pool is available within RECONNECT_TIMEOUT, the bridge exits and the distribution connection drops.

Started by `macula_dist_bridge_sup` (simple_one_for_one).

# Summary

## Functions

handle_call(Request, From, State)
handle_cast(Msg, State)
handle_info(Msg, State)
init(_)
start_link(Args)
terminate(Reason, State)

# Functions

# handle_call(Request, From, State)

# handle_cast(Msg, State)

# handle_info(Msg, State)

# init(_)

# start_link(Args)

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

# terminate(Reason, State)