From 8f83c2e8258a25a020ecdf6e5004fdef6e1bb49b Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Fri, 10 Jun 2016 00:22:04 -0400 Subject: [PATCH] Move RPCProxy.New() adjacent to its struct definition --- client/rpcproxy/rpcproxy.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/client/rpcproxy/rpcproxy.go b/client/rpcproxy/rpcproxy.go index 2541df010..bc28e7e52 100644 --- a/client/rpcproxy/rpcproxy.go +++ b/client/rpcproxy/rpcproxy.go @@ -133,6 +133,21 @@ type RpcProxy struct { notifyFailedBarrier int32 } +// New is the only way to safely create a new RpcProxy. +func New(logger *log.Logger, shutdownCh chan struct{}, configInfo NomadConfigInfo, connPoolPinger Pinger) (p *RpcProxy) { + p = new(RpcProxy) + p.logger = logger + p.configInfo = configInfo // can't pass *nomad.Client: import cycle + p.connPoolPinger = connPoolPinger // can't pass *nomad.ConnPool: import cycle + p.rebalanceTimer = time.NewTimer(clientRPCMinReuseDuration) + p.shutdownCh = shutdownCh + + l := serverList{} + l.L = make([]*ServerEndpoint, 0) + p.saveServerList(l) + return p +} + // activateEndpoint adds an endpoint to the RpcProxy's active serverList. // Returns true if the server was added, returns false if the server already // existed in the RpcProxy's serverList. @@ -316,21 +331,6 @@ func (p *RpcProxy) LeaderAddr() string { return p.leaderAddr } -// New is the only way to safely create a new RpcProxy. -func New(logger *log.Logger, shutdownCh chan struct{}, configInfo NomadConfigInfo, connPoolPinger Pinger) (p *RpcProxy) { - p = new(RpcProxy) - p.logger = logger - p.configInfo = configInfo // can't pass *nomad.Client: import cycle - p.connPoolPinger = connPoolPinger // can't pass *nomad.ConnPool: import cycle - p.rebalanceTimer = time.NewTimer(clientRPCMinReuseDuration) - p.shutdownCh = shutdownCh - - l := serverList{} - l.L = make([]*ServerEndpoint, 0) - p.saveServerList(l) - return p -} - // NotifyFailedServer marks the passed in server as "failed" by rotating it // to the end of the server list. func (p *RpcProxy) NotifyFailedServer(s *ServerEndpoint) {