cluster-discovery
Zero-configuration Bonjour peer discovery, local Thunderbolt/LAN link inspection, and deterministic rendezvous planning using github.com/tmc/apple/x/meshdisc (CGO_ENABLED=0, purego Network.framework).
What It Does
- Inspects local network interfaces via
meshdisc.LocalLinks() (net.Interfaces, nw_path_monitor, Thunderbolt bridge detection, and /dev/rdma* probe).
- Advertises the local Mac as an
_meshdisc._tcp Bonjour service using nw_listener, nw_advertise_descriptor, and nw_txt_record, attaching hardware (machdep.cpu.brand_string + RAM), CPU count, architecture, and Thunderbolt link metadata.
- Browses for
_meshdisc._tcp peers on the local host and LAN using nw_browser, resolving peer endpoints and TXT records.
- Builds a deterministic coordinator and rank assignment table via
meshdisc.BuildRendezvousConfig.
Usage
CGO_ENABLED=0 go run ./examples/network/cluster-discovery
Optional flags:
-service: Bonjour service type (default _meshdisc._tcp)
-name: Bonjour instance name (default hostname)
-id: node identifier (default instance name)
-rank: optional explicit rank hint in TXT record
-duration: browse window (default 2s)
-json: emit machine-readable JSON output
Verification
CGO_ENABLED=0 go vet ./x/meshdisc ./examples/network/cluster-discovery
CGO_ENABLED=0 go test -v -count=1 ./x/meshdisc ./examples/network/cluster-discovery
Measured Output (Apple M4 Max, 128 GB, macOS)
Cluster Discovery (_meshdisc._tcp)
Local node : m4max (id=m4max)
Hardware : Apple M4 Max (128GB)
Endpoint : 10.0.28.201:51453 (domain=local.)
Local Links (up or Thunderbolt):
bridge0 thunderbolt,tb mtu=1500 up=true (no ip)
lo0 loopback mtu=16384 up=true 127.0.0.1, ::1, fe80::1
en0 wifi,nw:wifi mtu=1500 up=true 10.0.28.201, fe80::cfe:20:d6f1:e93f, fda2:2d61:4f1f:8:8ce:1abe:8e54:7b1d, 2605:59c0:2064:8308:ce5:f8a9:8cd0:30a5, 2605:59c0:2064:8308:bdcb:f30f:667e:6ea6
awdl0 other mtu=1500 up=true fe80::a418:3eff:fee7:95dc
llw0 other mtu=1500 up=true fe80::a418:3eff:fee7:95dc
utun0 other mtu=1500 up=true fe80::3b6f:e4a:63:50fa
utun1 other mtu=1380 up=true fe80::e653:6781:312e:f9de
utun2 other mtu=2000 up=true fe80::56f6:142e:2436:d8af
utun3 other mtu=1000 up=true fe80::ce81:b1c:bd2c:69e
utun4 other mtu=1380 up=true fe80::6aee:4523:bcc2:a4c5
utun5 other mtu=1380 up=true fe80::ea49:c4ae:b2cd:2d1
utun6 other,nw:other mtu=1280 up=true 100.101.122.47, fe80::e498:985b:fd32:210a, fd7a:115c:a1e0::e801:7a2f
Discovered Peers (1):
- m4max (id=m4max host=10.0.28.201:51453 iface=lo0 tb=true hw="Apple M4 Max (128GB)")
TXT: arch=arm64 cpus=16 host=10.0.28.201 hw=Apple M4 Max (128GB) id=m4max port=51453 ram_gb=128 tb=1 tb_links=bridge0
Rendezvous Plan:
Coordinator : 10.0.28.201:51453 (id=m4max)
Backend : jaccl (thunderbolt_mesh=true world_size=1)
rank 0 : coordinator id=m4max addr=10.0.28.201:51453