Move RPCProxy.New() adjacent to its struct definition
This commit is contained in:
parent
447fe59fd2
commit
8dc16ad5e3
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue