refactor: simplify HA backend peer handling

- parsePeer: use net.SplitHostPort (handles IPv6, stdlib convention)
- tryConnect: take Go strings, own CGO allocation internally
- RegisterToBackend: remove unreachable 'no HA candidates' error path
- Sync Peers field comment between utils and backend config structs
This commit is contained in:
Rongsong Shen 2026-05-08 03:41:11 +00:00
parent 99d13f5254
commit da6d967a33
3 changed files with 26 additions and 36 deletions

View file

@ -18,10 +18,10 @@ type BackendConfig struct {
From string `yaml:"from"`
Key string `yaml:"key"`
// Peers lists additional controller candidates for HA mode in "host:port"
// format. When non-empty, RegisterToBackend iterates all candidates and
// connects to whichever responds as primary. Address+Port remain the
// single-host fallback when Peers is empty.
Peers []string `yaml:"peers"`
// format. When non-empty, RegisterToBackend tries each candidate in order
// and connects to whichever accepts the join as primary. Address+Port
// serve as a single-host fallback when Peers is empty.
Peers []string `yaml:"peers"`
}
type AppServerConfig struct {