Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
set default timeout for rest client
Browse files Browse the repository at this point in the history
  • Loading branch information
bgokden committed May 2, 2019
1 parent 765cf76 commit b4da2bf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ type authSuccess struct {

const defaultVersion = "v1"

const defaultTimeout = 30 * time.Second

func NewRestClient(url string, token string, version string, isVerbose bool, cert string) *restClient {
url = strings.TrimRight(url, "/") // Url should end without a /
resty.SetDebug(isVerbose)
Expand All @@ -121,6 +123,8 @@ func NewRestClient(url string, token string, version string, isVerbose bool, cer
// fmt.Printf("load cert from file: %v\n", tmpFile.Name())
resty.SetRootCertificate(tmpFile.Name())
}
// default timeout of golang is very long
resty.SetTimeout(defaultTimeout)
return &restClient{
url: url,
token: token,
Expand Down

0 comments on commit b4da2bf

Please sign in to comment.