Skip to content

Commit

Permalink
Tidied up timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyjameswilliams committed Mar 4, 2025
1 parent c08b825 commit f9d0df9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 10 additions & 0 deletions httpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"go.uber.org/zap"
)

const DefaultTimeout time.Duration = 5 * time.Second

// Master struct/object
type Client struct {
config *ClientConfig
Expand Down Expand Up @@ -105,6 +107,12 @@ func (c *ClientConfig) Build() (*Client, error) {

httpClient := c.HTTP

if c.CustomTimeout == 0 {
c.CustomTimeout = DefaultTimeout
}

httpClient.Timeout = c.CustomTimeout

cookieJar, err := cookiejar.New(nil)
if err != nil {
return nil, err
Expand All @@ -127,6 +135,8 @@ func (c *ClientConfig) Build() (*Client, error) {
)
}



client := &Client{
Integration: &c.Integration,
http: &httpClient,
Expand Down
4 changes: 0 additions & 4 deletions httpclient/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,6 @@ func (c *Client) request(ctx context.Context, method, endpoint string, body inte

req = req.WithContext(ctx)

// TEMPORARY HARD CODED TIMEOUT
c.http.Timeout = 5 * time.Second
////////////////////////////////

resp, err := c.http.Do(req)
if err != nil {
c.Sugar.Error("Failed to send request", zap.String("method", method), zap.String("endpoint", endpoint), zap.Error(err))
Expand Down

0 comments on commit f9d0df9

Please sign in to comment.