Skip to content

Commit a78a42a

Browse files
authored
feat: enhance connection pooling (#171)
1 parent f4466ca commit a78a42a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

client.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,18 @@ func NewClient(apiKey, apiSecret string) (*Client, error) {
5050
return nil, errors.New("API secret is empty")
5151
}
5252

53+
tr := http.DefaultTransport.(*http.Transport).Clone()
54+
tr.MaxIdleConnsPerHost = 5
55+
tr.IdleConnTimeout = 59 * time.Second // load balancer's idle timeout is 60 sec
56+
tr.ExpectContinueTimeout = 2 * time.Second
57+
5358
client := &Client{
5459
apiKey: apiKey,
5560
apiSecret: []byte(apiSecret),
5661
BaseURL: defaultBaseURL,
5762
HTTP: &http.Client{
58-
Timeout: defaultTimeout,
63+
Timeout: defaultTimeout,
64+
Transport: tr,
5965
},
6066
}
6167

0 commit comments

Comments
 (0)