From dd6da78aebd6d3363e5baba6ab0a46c588be4496 Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 6 Aug 2026 02:41:45 +0400 Subject: [PATCH] kiwix, weather: name the client timeout constant (V-581) Both clients used a bare 10*time.Second literal for the http.Client timeout, unlike websearch.DefaultTimeout which carries a comment explaining the number. Naming them puts the reason (LAN ZIM read vs. a public API over the internet) next to the value; the constants equal what was there before, so behaviour is unchanged. --- internal/kiwix/client.go | 7 ++++++- internal/weather/openmeteo.go | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/internal/kiwix/client.go b/internal/kiwix/client.go index f9962b7..52a218d 100644 --- a/internal/kiwix/client.go +++ b/internal/kiwix/client.go @@ -39,11 +39,16 @@ type Client struct { http *http.Client } +// clientTimeout — the whole request, search or article. The server is on the +// same box (see the package doc), so this is slack for a cold ZIM read, not a +// budget tuned against a flaky link the way websearch.DefaultTimeout is. +const clientTimeout = 10 * time.Second + // New makes a client for a Kiwix base URL like http://127.0.0.1:8034. func New(baseURL string) *Client { return &Client{ base: strings.TrimRight(baseURL, "/"), - http: &http.Client{Timeout: 10 * time.Second}, + http: &http.Client{Timeout: clientTimeout}, } } diff --git a/internal/weather/openmeteo.go b/internal/weather/openmeteo.go index 29818b9..9765155 100644 --- a/internal/weather/openmeteo.go +++ b/internal/weather/openmeteo.go @@ -13,13 +13,19 @@ import ( "github.com/kami/maven/internal/morph" ) +// clientTimeout — the whole request, geocode or forecast. Both are one call to +// a public API over the internet rather than a LAN service, hence longer than +// a bare "it's slow" budget; there is no retry behind it, so a slow reply +// still costs the caller the whole wait. +const clientTimeout = 10 * time.Second + type OpenMeteoProvider struct { httpClient *http.Client } func NewOpenMeteoProvider() *OpenMeteoProvider { return &OpenMeteoProvider{ - httpClient: &http.Client{Timeout: 10 * time.Second}, + httpClient: &http.Client{Timeout: clientTimeout}, } }