From 953a95f26fba8e8bad00ebce1b50e369e3a8350f Mon Sep 17 00:00:00 2001 From: Snider Date: Mon, 9 Mar 2026 14:19:10 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20address=20code=20review=20=E2=80=94=20HT?= =?UTF-8?q?TP=20client=20timeout,=20errors.Join,=20remove=20unused=20OnRel?= =?UTF-8?q?oad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - WaitForHealth: use http.Client with 2s timeout instead of DefaultClient - Daemon.Stop: use errors.Join for proper error unwrapping - Remove unused OnReload field from DaemonOptions Co-Authored-By: Claude Opus 4.6 --- daemon.go | 6 +----- health.go | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/daemon.go b/daemon.go index 96b76aa..30cbf29 100644 --- a/daemon.go +++ b/daemon.go @@ -26,10 +26,6 @@ type DaemonOptions struct { // HealthChecks are additional health check functions. HealthChecks []HealthCheck - - // OnReload is called when SIGHUP is received. - // Use for config reloading. Leave nil to ignore SIGHUP. - OnReload func() error } // Daemon manages daemon lifecycle: PID file, health server, graceful shutdown. @@ -135,7 +131,7 @@ func (d *Daemon) Stop() error { d.running = false if len(errs) > 0 { - return fmt.Errorf("shutdown errors: %v", errs) + return errors.Join(errs...) } return nil } diff --git a/health.go b/health.go index bf7a1cd..0f8563a 100644 --- a/health.go +++ b/health.go @@ -117,8 +117,10 @@ func WaitForHealth(addr string, timeoutMs int) bool { deadline := time.Now().Add(time.Duration(timeoutMs) * time.Millisecond) url := fmt.Sprintf("http://%s/health", addr) + client := &http.Client{Timeout: 2 * time.Second} + for time.Now().Before(deadline) { - resp, err := http.Get(url) + resp, err := client.Get(url) if err == nil { resp.Body.Close() if resp.StatusCode == http.StatusOK {