Skip to content

Commit 1cec3a8

Browse files
authored
Merge pull request #285 from deploymenttheory/dev-timeouts-fix
feat: added timeout changers
2 parents 99f092e + 6008e7c commit 1cec3a8

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

httpclient/client.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"go.uber.org/zap"
1818
)
1919

20-
const DefaultTimeout time.Duration = 5 * time.Second
20+
const DefaultTimeout time.Duration = 10 * time.Second
2121

2222
// Master struct/object
2323
type Client struct {
@@ -135,8 +135,6 @@ func (c *ClientConfig) Build() (*Client, error) {
135135
)
136136
}
137137

138-
139-
140138
client := &Client{
141139
Integration: &c.Integration,
142140
http: &httpClient,

httpclient/timeouts.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package httpclient
2+
3+
import (
4+
"sync"
5+
"time"
6+
)
7+
8+
var mu sync.Mutex
9+
10+
// Amends the HTTP timeout time
11+
func (c *Client) ModifyHttpTimeout(newTimeout time.Duration) {
12+
mu.Lock()
13+
defer mu.Unlock()
14+
c.http.Timeout = newTimeout
15+
}
16+
17+
// Resets HTTP timeout time back to 10 seconds
18+
func (c *Client) ResetTimeout() {
19+
mu.Lock()
20+
defer mu.Unlock()
21+
c.http.Timeout = DefaultTimeout
22+
}

0 commit comments

Comments
 (0)