Propage context in Ring

This commit is contained in:
Vladimir Mihailenco 2020-09-14 15:37:05 +03:00
parent 1a65d677b3
commit 4b9d6dfd40
1 changed files with 6 additions and 6 deletions

12
ring.go
View File

@ -565,8 +565,8 @@ func (c *Ring) cmdsInfo(ctx context.Context) (map[string]*CommandInfo, error) {
return nil, firstErr
}
func (c *Ring) cmdInfo(name string) *CommandInfo {
cmdsInfo, err := c.cmdsInfoCache.Get(c.ctx)
func (c *Ring) cmdInfo(ctx context.Context, name string) *CommandInfo {
cmdsInfo, err := c.cmdsInfoCache.Get(ctx)
if err != nil {
return nil
}
@ -577,8 +577,8 @@ func (c *Ring) cmdInfo(name string) *CommandInfo {
return info
}
func (c *Ring) cmdShard(cmd Cmder) (*ringShard, error) {
cmdInfo := c.cmdInfo(cmd.Name())
func (c *Ring) cmdShard(ctx context.Context, cmd Cmder) (*ringShard, error) {
cmdInfo := c.cmdInfo(ctx, cmd.Name())
pos := cmdFirstKeyPos(cmd, cmdInfo)
if pos == 0 {
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 {
return err
}
@ -661,7 +661,7 @@ func (c *Ring) generalProcessPipeline(
) error {
cmdsMap := make(map[string][]Cmder)
for _, cmd := range cmds {
cmdInfo := c.cmdInfo(cmd.Name())
cmdInfo := c.cmdInfo(ctx, cmd.Name())
hash := cmd.stringArg(cmdFirstKeyPos(cmd, cmdInfo))
if hash != "" {
hash = c.shards.Hash(hash)