diff --git a/examples/client.go b/examples/client.go index d8e0efe..2bed4ff 100644 --- a/examples/client.go +++ b/examples/client.go @@ -57,7 +57,7 @@ func main() { } //Create new configuration with default transport layer - config, err := realis.NewDefaultConfig(*url) + config, err := realis.NewDefaultConfig(*url, 10000) if err != nil { fmt.Println(err) os.Exit(1) diff --git a/realis.go b/realis.go index d8a477e..3760a20 100644 --- a/realis.go +++ b/realis.go @@ -69,7 +69,7 @@ func NewClient(config RealisConfig) Realis { } // Create a default configuration of the transport layer, requires a URL to test connection with. -func NewDefaultConfig(url string) (RealisConfig, error) { +func NewDefaultConfig(url string, timeoutms int) (RealisConfig, error) { jar, err := cookiejar.New(nil) if err != nil { @@ -78,7 +78,7 @@ func NewDefaultConfig(url string) (RealisConfig, error) { //Custom client to timeout after 10 seconds to avoid hanging trans, err := thrift.NewTHttpPostClientWithOptions(url+"/api", - thrift.THttpClientOptions{Client: &http.Client{Timeout: time.Second * 10, Jar: jar}}) + thrift.THttpClientOptions{Client: &http.Client{Timeout: time.Millisecond * time.Duration(timeoutms), Jar: jar}}) if err != nil { return RealisConfig{}, errors.Wrap(err, "Error creating transport")