Host liveness ready
Each agent registers a short-TTL lease at /coord/hosts/<host_uuid> and refreshes it in the background. Lease expiry is the cluster-wide signal that a host is down โ process death, network partition, kernel panic.
Pure-Go cross-host coordination on etcd v3 โ host liveness, watcher, and leader election. No cgo.
go-coord is a pure-Go (no cgo) cross-host coordination layer built on
etcd v3. It gives a fleet of agents the primitives they need to
coordinate high-availability behaviour: HostLiveness registers a short-TTL
lease and refreshes it in the background so lease expiry becomes the cluster-wide
host-down signal; HostWatcher turns that into an Up/Down
event stream; and Election / ElectionPool coalesce cross-host
work to a single leader per key. The keep-alive loop self-heals if etcd drops the
renewal stream, the caller owns the etcd connection, and the etcd client is a normal
build-from-source dependency โ nothing is vendored. 100% coverage, CI green across 6 arches.
Each agent registers a short-TTL lease at /coord/hosts/<host_uuid> and refreshes it in the background. Lease expiry is the cluster-wide signal that a host is down โ process death, network partition, kernel panic.
The keep-alive goroutine re-Grants + re-Puts + re-KeepAlives with exponential backoff if etcd drops the renewal stream (network blip, leader change, restart), so a transient hiccup doesn’t silently retire a healthy host forever.
A prefix watch emits HostEvent {Up|Down} on a channel. A fresh watcher first replays every existing host as a synthetic Up, and Down events carry the host’s last-seen metadata so consumers can name it without a separate lookup.
etcd-concurrency leader election scoped to a key: Campaign blocks until leader, TryCampaign is non-blocking, Resign allows succession, and Observe streams the current leader to followers.
One long-lived etcd session per election key, so cross-host work coalesces to a single leader per key without paying a grant/revoke cycle on every host-down ร key combination.
Seam-based unit tests drive every branch โ including the etcd grant/put/keepalive/watch error paths โ deterministically with in-package fakes on all six arches; embedded-etcd integration tests validate the whole thing end-to-end at 100% coverage.
CGO disabled, so it cross-compiles and embeds anywhere. The caller passes an
open *clientv3.Client; go-coord never fans out extra connections. Every branch โ
including the etcd grant / put / keepalive / watch error paths โ is covered by deterministic,
network-free seam tests that run on all six 64-bit Go arches (amd64, arm64, riscv64, loong64,
ppc64le, s390x), with embedded-etcd integration tests validating the whole thing end-to-end.