Merge the world sources sweep (#235)
Two bare client timeouts named. Everything else in kiwix, weather and websearch matched its description, including the measured dual-timeout transport that only the internet-facing SearXNG leg carries. Unifying that would undo V-508. Neither client sends anything but the query string. No note, fact or persona block reaches an upstream engine. Filed rather than fixed, V-589: the weather client checks no status code before decoding, so a non-200 becomes a successful zero-value answer. He is told it is 0 degrees, or that a city he named does not exist. (V-581)
This commit is contained in:
@@ -39,11 +39,16 @@ type Client struct {
|
|||||||
http *http.Client
|
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.
|
// New makes a client for a Kiwix base URL like http://127.0.0.1:8034.
|
||||||
func New(baseURL string) *Client {
|
func New(baseURL string) *Client {
|
||||||
return &Client{
|
return &Client{
|
||||||
base: strings.TrimRight(baseURL, "/"),
|
base: strings.TrimRight(baseURL, "/"),
|
||||||
http: &http.Client{Timeout: 10 * time.Second},
|
http: &http.Client{Timeout: clientTimeout},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,19 @@ import (
|
|||||||
"github.com/kami/maven/internal/morph"
|
"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 {
|
type OpenMeteoProvider struct {
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOpenMeteoProvider() *OpenMeteoProvider {
|
func NewOpenMeteoProvider() *OpenMeteoProvider {
|
||||||
return &OpenMeteoProvider{
|
return &OpenMeteoProvider{
|
||||||
httpClient: &http.Client{Timeout: 10 * time.Second},
|
httpClient: &http.Client{Timeout: clientTimeout},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user