Rename serverConfigMtx to serverConfigLock

Pointed out by: @slackpad
This commit is contained in:
Sean Chittenden 2016-02-19 13:19:13 -08:00
parent b1e392405c
commit 5be956c310
2 changed files with 12 additions and 12 deletions

View File

@ -56,7 +56,7 @@ type Client struct {
// serverConfig provides the necessary load/store semantics to // serverConfig provides the necessary load/store semantics to
// serverConfig // serverConfig
serverConfigValue atomic.Value serverConfigValue atomic.Value
serverConfigMtx sync.Mutex serverConfigLock sync.Mutex
// consulServersCh is used to receive events related to the // consulServersCh is used to receive events related to the
// maintenance of the list of consulServers // maintenance of the list of consulServers

View File

@ -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)