mirror of https://github.com/go-redis/redis.git
Naming consistency
This commit is contained in:
parent
e428ae1457
commit
ac4571386d
12
cluster.go
12
cluster.go
|
@ -18,8 +18,8 @@ type ClusterClient struct {
|
||||||
slots [][]string
|
slots [][]string
|
||||||
slotsMx sync.RWMutex // protects slots & addrs cache
|
slotsMx sync.RWMutex // protects slots & addrs cache
|
||||||
|
|
||||||
conns map[string]*Client
|
conns map[string]*Client
|
||||||
connMx sync.Mutex // protects conns
|
connsMx sync.Mutex // protects conns
|
||||||
|
|
||||||
opt *ClusterOptions
|
opt *ClusterOptions
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ func (c *ClusterClient) getMasterAddrBySlot(hashSlot int) string {
|
||||||
|
|
||||||
// Returns a node's client for a given address
|
// Returns a node's client for a given address
|
||||||
func (c *ClusterClient) getNodeClientByAddr(addr string) *Client {
|
func (c *ClusterClient) getNodeClientByAddr(addr string) *Client {
|
||||||
c.connMx.Lock()
|
c.connsMx.Lock()
|
||||||
client, ok := c.conns[addr]
|
client, ok := c.conns[addr]
|
||||||
if !ok {
|
if !ok {
|
||||||
opt := c.opt.clientOptions()
|
opt := c.opt.clientOptions()
|
||||||
|
@ -73,7 +73,7 @@ func (c *ClusterClient) getNodeClientByAddr(addr string) *Client {
|
||||||
client = NewTCPClient(opt)
|
client = NewTCPClient(opt)
|
||||||
c.conns[addr] = client
|
c.conns[addr] = client
|
||||||
}
|
}
|
||||||
c.connMx.Unlock()
|
c.connsMx.Unlock()
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,14 +170,14 @@ func (c *ClusterClient) reloadIfDue() (err error) {
|
||||||
|
|
||||||
// Closes all connections and flushes slots cache
|
// Closes all connections and flushes slots cache
|
||||||
func (c *ClusterClient) reset() (err error) {
|
func (c *ClusterClient) reset() (err error) {
|
||||||
c.connMx.Lock()
|
c.connsMx.Lock()
|
||||||
for addr, client := range c.conns {
|
for addr, client := range c.conns {
|
||||||
if e := client.Close(); e != nil {
|
if e := client.Close(); e != nil {
|
||||||
err = e
|
err = e
|
||||||
}
|
}
|
||||||
delete(c.conns, addr)
|
delete(c.conns, addr)
|
||||||
}
|
}
|
||||||
c.connMx.Unlock()
|
c.connsMx.Unlock()
|
||||||
c.slots = make([][]string, hashSlots)
|
c.slots = make([][]string, hashSlots)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue