-
Notifications
You must be signed in to change notification settings - Fork 26
/
client.go
43 lines (35 loc) · 849 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package http
import (
"net/http"
"time"
"github.com/0chain/gosdk/zboxcore/zboxutil"
"github.com/hashicorp/go-retryablehttp"
)
const (
RetryWaitMax = 120 * time.Second
RetryMax = 60
)
// NewClient creates default http.Client with timeouts.
func NewClient() *http.Client {
return &http.Client{
Transport: zboxutil.DefaultTransport,
}
}
func CleanClient() *http.Client {
client := &http.Client{
Transport: zboxutil.DefaultTransport,
}
client.Timeout = 250 * time.Second
return client
}
// NewRetryableClient creates default retryablehttp.Client with timeouts and embedded NewClient result.
func NewRetryableClient(verbose bool) *retryablehttp.Client {
client := retryablehttp.NewClient()
client.HTTPClient = &http.Client{
Transport: zboxutil.DefaultTransport,
}
if !verbose {
client.Logger = nil
}
return client
}