You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by mr...@apache.org on 2017/09/13 22:18:25 UTC
[incubator-openwhisk-client-go] branch master updated: Add the
default timeout for http request (#35)
This is an automated email from the ASF dual-hosted git repository.
mrutkowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new 00db68b Add the default timeout for http request (#35)
00db68b is described below
commit 00db68b4507d77e3202295ba2e3f86eab2598909
Author: Vincent <sh...@us.ibm.com>
AuthorDate: Wed Sep 13 18:18:24 2017 -0400
Add the default timeout for http request (#35)
This PR sets the default http timout to 60 seconds.
---
.travis.yml | 1 +
whisk/client.go | 14 +++++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index a6085a6..71fc279 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,7 @@ matrix:
include:
- os: linux
sudo: required
+ group: deprecated-2017Q3
go: 1.8
services: docker
diff --git a/whisk/client.go b/whisk/client.go
index 985bc75..c8cb311 100644
--- a/whisk/client.go
+++ b/whisk/client.go
@@ -31,6 +31,7 @@ import (
"reflect"
"github.com/apache/incubator-openwhisk-client-go/wski18n"
"strings"
+ "time"
)
const (
@@ -46,6 +47,7 @@ const (
DoNotProcessTimeOut = false
ExitWithErrorOnTimeout = true
ExitWithSuccessOnTimeout = false
+ DEFAULT_HTTP_TIMEOUT = 30
)
type Client struct {
@@ -91,6 +93,12 @@ func NewClient(httpClient *http.Client, config_input *Config) (*Client, error) {
config = config_input
}
+ if httpClient == nil {
+ httpClient = &http.Client{
+ Timeout: time.Second * DEFAULT_HTTP_TIMEOUT,
+ }
+ }
+
// Disable certificate checking in the dev environment if in insecure mode
if config.Insecure {
Debug(DbgInfo, "Disabling certificate checking.\n")
@@ -108,15 +116,11 @@ func NewClient(httpClient *http.Client, config_input *Config) (*Client, error) {
}
}
- http.DefaultClient.Transport = &http.Transport{
+ httpClient.Transport = &http.Transport{
TLSClientConfig: tlsConfig,
}
}
- if httpClient == nil {
- httpClient = http.DefaultClient
- }
-
var err error
var errStr = ""
if len(config.Host) == 0 {
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].