Skip to content

Commit

Permalink
Changed use of timeout, instead of setting it on the httpclient, set …
Browse files Browse the repository at this point in the history
…it in the consul client (#56)
  • Loading branch information
peterklijn authored Jul 29, 2020
1 parent 059c67c commit 85d728f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions monitor/consul/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,11 @@ func New(addr, dc, token string, timeout time.Duration, ii ...Item) (*Watcher, e
if len(ii) == 0 {
return nil, errors.New("items are empty")
}
if timeout == 0 {
timeout = 60 * time.Second
}
cfg := api.DefaultConfig()
cfg.Address = addr
var err error
cfg.HttpClient, err = api.NewHttpClient(cfg.Transport, cfg.TLSConfig)
if err != nil {
return nil, err
if timeout > 0 {
cfg.WaitTime = timeout
}
cfg.HttpClient.Timeout = timeout

cl, err := api.NewClient(cfg)
if err != nil {
Expand Down

0 comments on commit 85d728f

Please sign in to comment.