Skip to content

Commit

Permalink
setting default timeout in defaultHandlerConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Cerutti committed Sep 2, 2017
1 parent 17f0e0c commit 63693e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 4 additions & 4 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5947,7 +5947,7 @@ func TestServer_UpdateConfig(t *testing.T) {
Set: map[string]interface{}{
"token": "token",
"origin": "kapacitor",
"timeout": "24h0m0s",
"timeout": "24h",
},
},
expSection: client.ConfigSection{
Expand All @@ -5962,7 +5962,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"token-prefix": "",
"url": "http://alerta.example.com",
"insecure-skip-verify": false,
"timeout": "24h0m0s",
"timeout": "24h",
},
Redacted: []string{
"token",
Expand All @@ -5979,7 +5979,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"token-prefix": "",
"url": "http://alerta.example.com",
"insecure-skip-verify": false,
"timeout": "24h0m0s",
"timeout": "24h",
},
Redacted: []string{
"token",
Expand Down Expand Up @@ -8072,7 +8072,7 @@ func TestServer_AlertHandlers(t *testing.T) {
"origin": "kapacitor",
"group": "test",
"environment": "env",
"timeout": "24h0m0s",
"timeout": Time.duration(24 * time.Hour),
},
},
setup: func(c *server.Config, ha *client.TopicHandler) (context.Context, error) {
Expand Down
6 changes: 1 addition & 5 deletions services/alerta/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,6 @@ func (s *Service) preparePost(token, tokenPrefix, resource, event, environment,
origin = c.Origin
}

if timeout == 0 {
timeout = defaultTimeout
}

u, err := url.Parse(c.URL)
if err != nil {
return nil, err
Expand Down Expand Up @@ -281,7 +277,7 @@ type HandlerConfig struct {
Service []string `mapstructure:"service"`

// Alerta timeout.
// Default: 24h0m0s
// Default: 24h
Timeout time.Duration `mapstructure:"timeout"`
}

Expand Down

0 comments on commit 63693e6

Please sign in to comment.