Skip to content

Commit

Permalink
fix(etcd/client.go): add DialTimeout for 0.6.x
Browse files Browse the repository at this point in the history
This re-implements kelseyhightower#112 for confd 0.6.x.
  • Loading branch information
carmstrong committed Oct 6, 2014
1 parent 9d4410b commit 825c498
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backends/etcd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package etcd
import (
"errors"
"strings"
"time"

goetcd "github.com/coreos/go-etcd/etcd"
)
Expand All @@ -28,6 +29,8 @@ func NewEtcdClient(machines []string, cert, key string, caCert string) (*Client,
} else {
c = goetcd.NewClient(machines)
}
// Configure the DialTimeout, since 1 second is often too short
c.SetDialTimeout(time.Duration(3) * time.Second)
success := c.SetCluster(machines)
if !success {
return &Client{c}, errors.New("cannot connect to etcd cluster: " + strings.Join(machines, ","))
Expand Down

0 comments on commit 825c498

Please sign in to comment.