macula_relay_discovery (macula v1.4.30)
View SourceRelay Discovery — geographic-aware relay selection.
Maintains a ranked list of relay identities sorted by distance from the node's own location. Updated via three mechanisms:
1. Bootstrap: HTTP GET /topology from seed relays on startup 2. Real-time: _mesh.relay.up/down events via pubsub subscription 3. Periodic: Reconciliation poll every 5 minutes
Nodes connect to the nearest available relay. On failover, the next nearest is selected instantly from the cached ranked list.
Usage: {ok, Pid} = macula_relay_discovery:start_link(Opts). {ok, Url} = macula_relay_discovery:nearest(). {ok, Url} = macula_relay_discovery:nearest_except(FailedHostname). Relays = macula_relay_discovery:ranked_relays().