diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-04-14 10:35:01 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-04-14 12:24:51 +0200 |
commit | cce3b08cbe1864e80d5b9e57891622706b1d8181 (patch) | |
tree | 648c19acee2eb853a2a8662b1e87540b45c784dd /client | |
parent | 86c3219f28f89a0c5c4c15415b65f4d5a81b8774 (diff) |
Adjust request timeout like Java client
Diffstat (limited to 'client')
-rw-r--r-- | client/go/internal/vespa/document/http.go | 8 | ||||
-rw-r--r-- | client/go/internal/vespa/document/http_test.go | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/client/go/internal/vespa/document/http.go b/client/go/internal/vespa/document/http.go index d602821d603..1bcd7eff39e 100644 --- a/client/go/internal/vespa/document/http.go +++ b/client/go/internal/vespa/document/http.go @@ -72,9 +72,13 @@ func NewClient(options ClientOptions, httpClients []util.HTTPClient) *Client { func (c *Client) queryParams() url.Values { params := url.Values{} - if c.options.Timeout > 0 { - params.Set("timeout", strconv.FormatInt(c.options.Timeout.Milliseconds(), 10)+"ms") + timeout := c.options.Timeout + if timeout == 0 { + timeout = 200 * time.Second + } else { + timeout = timeout*11/10 + 1000 } + params.Set("timeout", strconv.FormatInt(timeout.Milliseconds(), 10)+"ms") if c.options.Route != "" { params.Set("route", c.options.Route) } diff --git a/client/go/internal/vespa/document/http_test.go b/client/go/internal/vespa/document/http_test.go index 43eaf1bfdf9..8f8394a5d4e 100644 --- a/client/go/internal/vespa/document/http_test.go +++ b/client/go/internal/vespa/document/http_test.go @@ -108,7 +108,7 @@ func TestClientSend(t *testing.T) { if r.Method != http.MethodPut { t.Errorf("got r.Method = %q, want %q", r.Method, http.MethodPut) } - wantURL := fmt.Sprintf("https://example.com:1337/document/v1/ns/type/docid/%s?create=true&timeout=5000ms", doc.Id.UserSpecific) + wantURL := fmt.Sprintf("https://example.com:1337/document/v1/ns/type/docid/%s?create=true&timeout=5500ms", doc.Id.UserSpecific) if r.URL.String() != wantURL { t.Errorf("got r.URL = %q, want %q", r.URL, wantURL) } |