Rename serverConfigMtx to serverConfigLock
Pointed out by: @slackpad
This commit is contained in:
parent
49425c5371
commit
2a52d3eb80
|
@ -46,8 +46,8 @@ func (c *Client) consulServersManager() {
|
||||||
defaultTimeout := 5 * time.Second // FIXME(sean@): This is a bullshit value
|
defaultTimeout := 5 * time.Second // FIXME(sean@): This is a bullshit value
|
||||||
var rebalanceTimer *time.Timer
|
var rebalanceTimer *time.Timer
|
||||||
func(c *Client) {
|
func(c *Client) {
|
||||||
c.serverConfigMtx.Lock()
|
c.serverConfigLock.Lock()
|
||||||
defer c.serverConfigMtx.Unlock()
|
defer c.serverConfigLock.Unlock()
|
||||||
|
|
||||||
serverCfgPtr := c.serverConfigValue.Load()
|
serverCfgPtr := c.serverConfigValue.Load()
|
||||||
if serverCfgPtr == nil {
|
if serverCfgPtr == nil {
|
||||||
|
@ -97,8 +97,8 @@ func (c *Client) consulServersManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) AddServer(server *serverParts) {
|
func (c *Client) AddServer(server *serverParts) {
|
||||||
c.serverConfigMtx.Lock()
|
c.serverConfigLock.Lock()
|
||||||
defer c.serverConfigMtx.Unlock()
|
defer c.serverConfigLock.Unlock()
|
||||||
serverCfg := c.serverConfigValue.Load().(serverConfig)
|
serverCfg := c.serverConfigValue.Load().(serverConfig)
|
||||||
|
|
||||||
// Check if this server is known
|
// Check if this server is known
|
||||||
|
@ -126,8 +126,8 @@ func (c *Client) AddServer(server *serverParts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CycleFailedServers() {
|
func (c *Client) CycleFailedServers() {
|
||||||
c.serverConfigMtx.Lock()
|
c.serverConfigLock.Lock()
|
||||||
defer c.serverConfigMtx.Unlock()
|
defer c.serverConfigLock.Unlock()
|
||||||
serverCfg := c.serverConfigValue.Load().(serverConfig)
|
serverCfg := c.serverConfigValue.Load().(serverConfig)
|
||||||
|
|
||||||
for i := range serverCfg.servers {
|
for i := range serverCfg.servers {
|
||||||
|
@ -157,8 +157,8 @@ func (sc *serverConfig) cycleServer() (servers []*serverParts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) RebalanceServers() {
|
func (c *Client) RebalanceServers() {
|
||||||
c.serverConfigMtx.Lock()
|
c.serverConfigLock.Lock()
|
||||||
defer c.serverConfigMtx.Unlock()
|
defer c.serverConfigLock.Unlock()
|
||||||
serverCfg := c.serverConfigValue.Load().(serverConfig)
|
serverCfg := c.serverConfigValue.Load().(serverConfig)
|
||||||
|
|
||||||
// Shuffle the server list on server join. Servers are selected from
|
// Shuffle the server list on server join. Servers are selected from
|
||||||
|
@ -174,8 +174,8 @@ func (c *Client) RebalanceServers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) RemoveServer(server *serverParts) {
|
func (c *Client) RemoveServer(server *serverParts) {
|
||||||
c.serverConfigMtx.Lock()
|
c.serverConfigLock.Lock()
|
||||||
defer c.serverConfigMtx.Unlock()
|
defer c.serverConfigLock.Unlock()
|
||||||
serverCfg := c.serverConfigValue.Load().(serverConfig)
|
serverCfg := c.serverConfigValue.Load().(serverConfig)
|
||||||
|
|
||||||
// Remove the server if known
|
// Remove the server if known
|
||||||
|
@ -194,7 +194,7 @@ func (c *Client) RemoveServer(server *serverParts) {
|
||||||
|
|
||||||
// resetRebalanceTimer assumes:
|
// resetRebalanceTimer assumes:
|
||||||
//
|
//
|
||||||
// 1) the serverConfigMtx is already held by the caller.
|
// 1) the serverConfigLock is already held by the caller.
|
||||||
// 2) the caller will call serverConfigValue.Store()
|
// 2) the caller will call serverConfigValue.Store()
|
||||||
func (sc *serverConfig) resetRebalanceTimer(c *Client) {
|
func (sc *serverConfig) resetRebalanceTimer(c *Client) {
|
||||||
numConsulServers := len(sc.servers)
|
numConsulServers := len(sc.servers)
|
||||||
|
|
Loading…
Reference in New Issue