feat: add HA candidate failover to API server backend
- BackendConfig.Peers []string carries host:port candidates from YAML (backend.peers) - RegisterToBackend iterates Peers in order, connecting to first responsive primary - parsePeer extracted to peers.go (no build tag) so it's testable without CGO - Single-host path (no Peers) preserved unchanged - Tests: parsePeer table-driven (11 cases), stub RegisterToBackend with/without peers
This commit is contained in:
parent
9bc84f1ca1
commit
99d13f5254
7 changed files with 213 additions and 16 deletions
|
|
@ -66,6 +66,7 @@ func main() {
|
|||
Port: utils.BackendYamlConfig.Port,
|
||||
From: utils.BackendYamlConfig.From,
|
||||
Key: utils.BackendYamlConfig.Key,
|
||||
Peers: utils.BackendYamlConfig.Peers,
|
||||
}
|
||||
if err := backend.RegisterToBackend(bcfg); err != nil {
|
||||
logger.Error("Failed to connect to backend", zap.Error(err))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue