diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-05-24 13:03:36 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-05-24 13:03:36 +0200 |
commit | 06f76e42fd96860d82a79ab5738cd4968ea60388 (patch) | |
tree | ff315c98c284bbb6fcb0f1934a22fe7c77cc7df1 /client | |
parent | ca478cb618bfd8517dcb3b1a01f12b83077d7d30 (diff) |
Do not copy countingHTTPClient
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, 5 insertions, 5 deletions
diff --git a/client/go/internal/vespa/document/http.go b/client/go/internal/vespa/document/http.go index 8ea28203c28..0c27b0d5440 100644 --- a/client/go/internal/vespa/document/http.go +++ b/client/go/internal/vespa/document/http.go @@ -44,7 +44,7 @@ var ( // Client represents a HTTP client for the /document/v1/ API. type Client struct { options ClientOptions - httpClients []countingHTTPClient + httpClients []*countingHTTPClient now func() time.Time sendCount atomic.Int32 gzippers sync.Pool @@ -90,9 +90,9 @@ func NewClient(options ClientOptions, httpClients []util.HTTPClient) (*Client, e if err != nil { return nil, fmt.Errorf("invalid base url: %w", err) } - countingClients := make([]countingHTTPClient, 0, len(httpClients)) + countingClients := make([]*countingHTTPClient, 0, len(httpClients)) for _, client := range httpClients { - countingClients = append(countingClients, countingHTTPClient{client: client}) + countingClients = append(countingClients, &countingHTTPClient{client: client}) } nowFunc := options.NowFunc if nowFunc == nil { @@ -196,7 +196,7 @@ func (c *Client) leastBusyClient() *countingHTTPClient { } } leastBusy.inflight.Add(1) - return &leastBusy + return leastBusy } func (c *Client) gzipWriter(w io.Writer) *gzip.Writer { diff --git a/client/go/internal/vespa/document/http_test.go b/client/go/internal/vespa/document/http_test.go index bfcd15c6070..b34b322f6eb 100644 --- a/client/go/internal/vespa/document/http_test.go +++ b/client/go/internal/vespa/document/http_test.go @@ -39,7 +39,7 @@ func TestLeastBusyClient(t *testing.T) { client.httpClients[0].inflight.Add(1) client.httpClients[1].inflight.Add(1) assertLeastBusy(t, 2, client) - assertLeastBusy(t, 2, client) + assertLeastBusy(t, 3, client) assertLeastBusy(t, 3, client) client.httpClients[3].inflight.Add(1) client.httpClients[1].inflight.Add(-1) |