From b4da2bf40ba61cb0cc1a71fb1900aae941319c60 Mon Sep 17 00:00:00 2001 From: berkgokden Date: Thu, 2 May 2019 13:15:14 +0200 Subject: [PATCH] set default timeout for rest client --- client/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/client.go b/client/client.go index 6f8cd70..5ff093b 100644 --- a/client/client.go +++ b/client/client.go @@ -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) @@ -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,