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

@ -14,15 +14,6 @@ func TestStartHeartbeat_StubNoOp(t *testing.T) {
StartHeartbeat(context.Background())
}
// TestSetHeartbeatInterval_StubNoOp verifies the no-CGO stub for
// SetHeartbeatInterval is a no-op that does not panic.
func TestSetHeartbeatInterval_StubNoOp(t *testing.T) {
// Should not panic and completes immediately
SetHeartbeatInterval(30)
SetHeartbeatInterval(0)
SetHeartbeatInterval(-1)
}
// TestEvalSelectForHost_StubErrNoCGO verifies the no-CGO stub for
// EvalSelectForHost returns errNoCGO, blocking callers from using
// select expressions without the real CGO backend.