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}, } }