Skip to content
This repository was archived by the owner on Jun 8, 2024. It is now read-only.

Commit bb92d1b

Browse files
committed
Tweak request timeouts
1 parent 952954b commit bb92d1b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

internal/groovestats/client.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ func (e *DisabledError) Error() string {
2727
}
2828

2929
type Client struct {
30-
client *http.Client
30+
getClient *http.Client
31+
postClient *http.Client
3132
cache *lru.Cache
3233
logger *log.Logger
3334

@@ -42,7 +43,8 @@ func NewClient() *Client {
4243
logger := log.New(log.Writer(), "[GS] ", log.LstdFlags|log.Lmsgprefix)
4344

4445
return &Client{
45-
client: &http.Client{Timeout: 15 * time.Second},
46+
getClient: &http.Client{Timeout: 12 * time.Second},
47+
postClient: &http.Client{Timeout: 32 * time.Second},
4648
cache: cache,
4749
logger: logger,
4850

@@ -314,7 +316,14 @@ func (client *Client) doRequest(req *http.Request, response interface{}) error {
314316
return &DisabledError{reason: "request not sent due to protocol violation"}
315317
}
316318

317-
resp, err := client.client.Do(req)
319+
var resp *http.Response
320+
var err error
321+
322+
if req.Method == "GET" {
323+
resp, err = client.getClient.Do(req)
324+
} else {
325+
resp, err = client.postClient.Do(req)
326+
}
318327
if err != nil {
319328
return err
320329
}

0 commit comments

Comments
 (0)