Skip to content

Commit

Permalink
using GetDuration in HTTP reporter timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostec committed Sep 27, 2018
1 parent f75f912 commit db54415
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ reporters:
host: "0.0.0.0:8125"
prefix: "maestro."
region: "region"
http:
timeout: "5s"
putURL: "localhost:8080"
region: "region"
scaleUpTimeoutSeconds: 600
scaleDownTimeoutSeconds: 600
deleteTimeoutSeconds: 600
Expand Down
4 changes: 4 additions & 0 deletions config/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ reporters:
host: "0.0.0.0:8125"
prefix: "test."
region: "test"
http:
timeout: "5s"
putURL: "localhost:8080"
region: "test"
scaleUpTimeoutSeconds: 300
scaleDownTimeoutSeconds: 300
deleteTimeoutSeconds: 300
Expand Down
6 changes: 3 additions & 3 deletions reporters/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ func MakeHTTP(config *viper.Viper, logger *logrus.Logger, r *Reporters) {
func loadDefaultHTTPConfigs(c *viper.Viper) {
c.SetDefault("reporters.http.putURL", "http://localhost:8080")
c.SetDefault("reporters.http.region", "test")
c.SetDefault("reporters.http.timeoutMs", "5000")
c.SetDefault("reporters.http.timeout", "5s")
}

// NewHTTP creates an HTTP struct using putURL and region from config
func NewHTTP(config *viper.Viper, logger *logrus.Logger) (*HTTP, error) {
loadDefaultHTTPConfigs(config)
putURL := config.GetString("reporters.http.putURL")
region := config.GetString("reporters.http.region")
timeoutMs := config.GetInt64("reporters.http.timeoutMs")
client := NewHTTPClient(putURL, time.Duration(timeoutMs)*time.Millisecond)
timeout := config.GetDuration("reporters.http.timeout")
client := NewHTTPClient(putURL, timeout)
httpR := &HTTP{client: client, region: region}
return httpR, nil
}
Expand Down

0 comments on commit db54415

Please sign in to comment.