Documentation
¶
Overview ¶
Package heartbeat is a tiny idle-heartbeat helper for long blocking calls (an LLM stream between deltas, a single MCP tool call) that otherwise produce zero log output while waiting. Silence during a multi-minute wait is indistinguishable from a hang; a heartbeat every Interval turns that silence into an explicit "still waiting" signal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Interval = 30 * time.Second
Interval is how often an idle heartbeat fires while Touch hasn't been called. Mutable for testing (shrunk so a heartbeat test doesn't eat real wall-clock time), mirroring the connectTimeout / connectOuterGrace mutable-for-testing pattern in internal/pkg/mcp/manager.go.
Functions ¶
This section is empty.
Types ¶
type H ¶
type H struct {
// contains filtered or unexported fields
}
H ticks a background goroutine that logs a DEBUG "still waiting" line every Interval while the guarded call hasn't completed or produced activity. Touch resets the idle clock (call it on every unit of progress — a stream delta, a progress notification); Stop cancels the ticker goroutine cleanly. Safe for concurrent use: lastActivity is updated via atomic so the ticker goroutine reading it never races Touch's writer.
func Start ¶
Start launches the idle-heartbeat goroutine, logging msg (plus attrs) via ctx's logger (scope.GetLogger) every Interval of inactivity. Stop must be called (typically deferred) once the guarded call returns, success or error, so the goroutine doesn't leak.