Skip to content

Commit f9d0df9

Browse files
Tidied up timeout
1 parent c08b825 commit f9d0df9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

httpclient/client.go

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
"go.uber.org/zap"
1818
)
1919

20+
const DefaultTimeout time.Duration = 5 * time.Second
21+
2022
// Master struct/object
2123
type Client struct {
2224
config *ClientConfig
@@ -105,6 +107,12 @@ func (c *ClientConfig) Build() (*Client, error) {
105107

106108
httpClient := c.HTTP
107109

110+
if c.CustomTimeout == 0 {
111+
c.CustomTimeout = DefaultTimeout
112+
}
113+
114+
httpClient.Timeout = c.CustomTimeout
115+
108116
cookieJar, err := cookiejar.New(nil)
109117
if err != nil {
110118
return nil, err
@@ -127,6 +135,8 @@ func (c *ClientConfig) Build() (*Client, error) {
127135
)
128136
}
129137

138+
139+
130140
client := &Client{
131141
Integration: &c.Integration,
132142
http: &httpClient,

httpclient/request.go

-4
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,6 @@ func (c *Client) request(ctx context.Context, method, endpoint string, body inte
272272

273273
req = req.WithContext(ctx)
274274

275-
// TEMPORARY HARD CODED TIMEOUT
276-
c.http.Timeout = 5 * time.Second
277-
////////////////////////////////
278-
279275
resp, err := c.http.Do(req)
280276
if err != nil {
281277
c.Sugar.Error("Failed to send request", zap.String("method", method), zap.String("endpoint", endpoint), zap.Error(err))

0 commit comments

Comments
 (0)