From fcbb615aa03811c09aba9d7dccbaff766237b63b Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 15 Mar 2017 08:02:14 -0700 Subject: [PATCH] Cleans up some small things based on review feedback. --- consul/pool.go | 6 ++++-- consul/servers/manager.go | 2 +- consul/servers/router.go | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/consul/pool.go b/consul/pool.go index 9c8a6125d9..2e83e7a1be 100644 --- a/consul/pool.go +++ b/consul/pool.go @@ -16,6 +16,8 @@ import ( "github.com/hashicorp/yamux" ) +const defaultDialTimeout = 10 * time.Second + // muxSession is used to provide an interface for a stream multiplexer. type muxSession interface { Open() (net.Conn, error) @@ -261,7 +263,7 @@ type HalfCloser interface { // given connection timeout. func (p *ConnPool) DialTimeout(dc string, addr string, timeout time.Duration) (net.Conn, HalfCloser, error) { // Try to dial the conn - conn, err := net.DialTimeout("tcp", addr, 10*time.Second) + conn, err := net.DialTimeout("tcp", addr, defaultDialTimeout) if err != nil { return nil, nil, err } @@ -297,7 +299,7 @@ func (p *ConnPool) DialTimeout(dc string, addr string, timeout time.Duration) (n // getNewConn is used to return a new connection func (p *ConnPool) getNewConn(dc string, addr string, version int) (*Conn, error) { // Get a new, raw connection. - conn, _, err := p.DialTimeout(dc, addr, 10*time.Second) + conn, _, err := p.DialTimeout(dc, addr, defaultDialTimeout) if err != nil { return nil, err } diff --git a/consul/servers/manager.go b/consul/servers/manager.go index 5b316e2f32..99e3e7a19c 100644 --- a/consul/servers/manager.go +++ b/consul/servers/manager.go @@ -236,7 +236,7 @@ func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ManagerSerfCl m.connPoolPinger = connPoolPinger // can't pass *consul.ConnPool: import cycle m.rebalanceTimer = time.NewTimer(clientRPCMinReuseDuration) m.shutdownCh = shutdownCh - m.offline = 1 + atomic.StoreInt32(&m.offline, 1) l := serverList{} l.servers = make([]*agent.Server, 0) diff --git a/consul/servers/router.go b/consul/servers/router.go index 3255c66daf..db9c31f6ec 100644 --- a/consul/servers/router.go +++ b/consul/servers/router.go @@ -71,7 +71,7 @@ type areaInfo struct { managers map[string]*managerInfo } -// NewRouter returns a new router with the given configuration. This will also +// NewRouter returns a new Router with the given configuration. This will also // spawn a goroutine that cleans up when the given shutdownCh is closed. func NewRouter(logger *log.Logger, shutdownCh chan struct{}, localDatacenter string) *Router { router := &Router{