commit
841ef09bbb
2 changed files with 3 additions and 3 deletions
|
@ -57,7 +57,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create new configuration with default transport layer
|
//Create new configuration with default transport layer
|
||||||
config, err := realis.NewDefaultConfig(*url)
|
config, err := realis.NewDefaultConfig(*url, 10000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
@ -69,7 +69,7 @@ func NewClient(config RealisConfig) Realis {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a default configuration of the transport layer, requires a URL to test connection with.
|
// 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)
|
jar, err := cookiejar.New(nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -78,7 +78,7 @@ func NewDefaultConfig(url string) (RealisConfig, error) {
|
||||||
|
|
||||||
//Custom client to timeout after 10 seconds to avoid hanging
|
//Custom client to timeout after 10 seconds to avoid hanging
|
||||||
trans, err := thrift.NewTHttpPostClientWithOptions(url+"/api",
|
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 {
|
if err != nil {
|
||||||
return RealisConfig{}, errors.Wrap(err, "Error creating transport")
|
return RealisConfig{}, errors.Wrap(err, "Error creating transport")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue