mirror of https://github.com/go-redis/redis.git
Propage context in Ring
This commit is contained in:
parent
1a65d677b3
commit
4b9d6dfd40
12
ring.go
12
ring.go
|
@ -565,8 +565,8 @@ func (c *Ring) cmdsInfo(ctx context.Context) (map[string]*CommandInfo, error) {
|
||||||
return nil, firstErr
|
return nil, firstErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Ring) cmdInfo(name string) *CommandInfo {
|
func (c *Ring) cmdInfo(ctx context.Context, name string) *CommandInfo {
|
||||||
cmdsInfo, err := c.cmdsInfoCache.Get(c.ctx)
|
cmdsInfo, err := c.cmdsInfoCache.Get(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -577,8 +577,8 @@ func (c *Ring) cmdInfo(name string) *CommandInfo {
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Ring) cmdShard(cmd Cmder) (*ringShard, error) {
|
func (c *Ring) cmdShard(ctx context.Context, cmd Cmder) (*ringShard, error) {
|
||||||
cmdInfo := c.cmdInfo(cmd.Name())
|
cmdInfo := c.cmdInfo(ctx, cmd.Name())
|
||||||
pos := cmdFirstKeyPos(cmd, cmdInfo)
|
pos := cmdFirstKeyPos(cmd, cmdInfo)
|
||||||
if pos == 0 {
|
if pos == 0 {
|
||||||
return c.shards.Random()
|
return c.shards.Random()
|
||||||
|
@ -605,7 +605,7 @@ func (c *Ring) _process(ctx context.Context, cmd Cmder) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shard, err := c.cmdShard(cmd)
|
shard, err := c.cmdShard(ctx, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ func (c *Ring) generalProcessPipeline(
|
||||||
) error {
|
) error {
|
||||||
cmdsMap := make(map[string][]Cmder)
|
cmdsMap := make(map[string][]Cmder)
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmds {
|
||||||
cmdInfo := c.cmdInfo(cmd.Name())
|
cmdInfo := c.cmdInfo(ctx, cmd.Name())
|
||||||
hash := cmd.stringArg(cmdFirstKeyPos(cmd, cmdInfo))
|
hash := cmd.stringArg(cmdFirstKeyPos(cmd, cmdInfo))
|
||||||
if hash != "" {
|
if hash != "" {
|
||||||
hash = c.shards.Hash(hash)
|
hash = c.shards.Hash(hash)
|
||||||
|
|
Loading…
Reference in New Issue