diff --git a/httpclient/client.go b/httpclient/client.go index 281052c..c301c52 100644 --- a/httpclient/client.go +++ b/httpclient/client.go @@ -17,7 +17,7 @@ import ( "go.uber.org/zap" ) -const DefaultTimeout time.Duration = 5 * time.Second +const DefaultTimeout time.Duration = 10 * time.Second // Master struct/object type Client struct { @@ -135,8 +135,6 @@ func (c *ClientConfig) Build() (*Client, error) { ) } - - client := &Client{ Integration: &c.Integration, http: &httpClient, diff --git a/httpclient/timeouts.go b/httpclient/timeouts.go new file mode 100644 index 0000000..c228797 --- /dev/null +++ b/httpclient/timeouts.go @@ -0,0 +1,22 @@ +package httpclient + +import ( + "sync" + "time" +) + +var mu sync.Mutex + +// Amends the HTTP timeout time +func (c *Client) ModifyHttpTimeout(newTimeout time.Duration) { + mu.Lock() + defer mu.Unlock() + c.http.Timeout = newTimeout +} + +// Resets HTTP timeout time back to 10 seconds +func (c *Client) ResetTimeout() { + mu.Lock() + defer mu.Unlock() + c.http.Timeout = DefaultTimeout +}