feat: P1-3 add heartbeat keep-alive goroutine

- add heartbeat.go with heartbeatIntervalSecs var, SetHeartbeatInterval, runHeartbeat (no build tag, CGO-free)
- add heartbeat_test.go with 5 tests covering interval validation and goroutine lifecycle
- add StartHeartbeat to clib.go (CGO impl calling xcecli_heartbeat)
- remove SetHeartbeatInterval stub from stub.go (now real code in heartbeat.go)
- remove TestSetHeartbeatInterval_StubNoOp from stub_funcs_test.go
- call SetHeartbeatInterval in OnClusterUpdated to track backend-pushed interval
- call backend.StartHeartbeat in cmd/main.go after backend registration
This commit is contained in:
Rongsong Shen 2026-04-17 14:12:40 +00:00
parent bc3103a6d5
commit ffc5b20cdb
7 changed files with 125 additions and 12 deletions

View file

@ -9,6 +9,7 @@ import (
"apiserver/store"
"apiserver/utils"
logger "apiserver/utils"
"context"
"flag"
"fmt"
"io"
@ -71,6 +72,7 @@ func main() {
os.Exit(1)
}
logger.Info("********** Backend connection registered!")
backend.StartHeartbeat(context.Background())
} else {
logger.Info("********** Backend not configured — running in stub mode")
}