Search documentation of macula

# macula_dist_bridge (macula v0.44.2)

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 relay) - A writer loop (handle_info, receives from relay -> writes to socket) - Metrics counters for the tunnel - A relay subscription (unsubscribed on terminate)

### Relay Reconnection

The relay_client replays subscriptions on reconnect, so the bridge's incoming data (tunnel_in messages) resumes automatically. The reader handles publish failures by retrying — if the relay client is temporarily disconnected, publishes buffer in its gen_server mailbox and flush when the QUIC connection is re-established.

If the relay client PID dies (process crash, not just QUIC drop), the bridge attempts to re-acquire a new client from persistent_term and re-subscribe. If no client 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)