diff options
Diffstat (limited to 'vendor/github.com/go-redis/redis/ring.go')
-rw-r--r-- | vendor/github.com/go-redis/redis/ring.go | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/vendor/github.com/go-redis/redis/ring.go b/vendor/github.com/go-redis/redis/ring.go index 6d2877413..b47a1094e 100644 --- a/vendor/github.com/go-redis/redis/ring.go +++ b/vendor/github.com/go-redis/redis/ring.go @@ -304,10 +304,11 @@ func NewRing(opt *RingOptions) *Ring { opt.init() ring := &Ring{ - opt: opt, - shards: newRingShards(), - cmdsInfoCache: newCmdsInfoCache(), + opt: opt, + shards: newRingShards(), } + ring.cmdsInfoCache = newCmdsInfoCache(ring.cmdsInfo) + ring.processPipeline = ring.defaultProcessPipeline ring.cmdable.setProcessor(ring.Process) @@ -428,21 +429,23 @@ func (c *Ring) ForEachShard(fn func(client *Client) error) error { } } -func (c *Ring) cmdInfo(name string) *CommandInfo { - cmdsInfo, err := c.cmdsInfoCache.Do(func() (map[string]*CommandInfo, error) { - shards := c.shards.List() - firstErr := errRingShardsDown - for _, shard := range shards { - cmdsInfo, err := shard.Client.Command().Result() - if err == nil { - return cmdsInfo, nil - } - if firstErr == nil { - firstErr = err - } +func (c *Ring) cmdsInfo() (map[string]*CommandInfo, error) { + shards := c.shards.List() + firstErr := errRingShardsDown + for _, shard := range shards { + cmdsInfo, err := shard.Client.Command().Result() + if err == nil { + return cmdsInfo, nil } - return nil, firstErr - }) + if firstErr == nil { + firstErr = err + } + } + return nil, firstErr +} + +func (c *Ring) cmdInfo(name string) *CommandInfo { + cmdsInfo, err := c.cmdsInfoCache.Get() if err != nil { return nil } @@ -522,7 +525,7 @@ func (c *Ring) defaultProcessPipeline(cmds []Cmder) error { continue } - cn, _, err := shard.Client.getConn() + cn, err := shard.Client.getConn() if err != nil { setCmdsErr(cmds, err) continue @@ -530,10 +533,10 @@ func (c *Ring) defaultProcessPipeline(cmds []Cmder) error { canRetry, err := shard.Client.pipelineProcessCmds(cn, cmds) if err == nil || internal.IsRedisError(err) { - _ = shard.Client.connPool.Put(cn) + shard.Client.connPool.Put(cn) continue } - _ = shard.Client.connPool.Remove(cn) + shard.Client.connPool.Remove(cn) if canRetry && internal.IsRetryableError(err, true) { if failedCmdsMap == nil { |