1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00

Add test for ring and cluster hooks

This commit is contained in:
Vladimir Mihailenco
2020-02-14 14:30:07 +02:00
parent 2e3402d33d
commit 49a0c8c319
7 changed files with 433 additions and 44 deletions

14
ring.go
View File

@ -581,7 +581,7 @@ func (c *Ring) _process(ctx context.Context, cmd Cmder) error {
return err
}
lastErr = shard.Client._process(ctx, cmd)
lastErr = shard.Client.ProcessContext(ctx, cmd)
if lastErr == nil || !isRetryableError(lastErr, cmd.readTimeout() == nil) {
return lastErr
}
@ -646,10 +646,7 @@ func (c *Ring) generalProcessPipeline(
go func(hash string, cmds []Cmder) {
defer wg.Done()
err := c.processShardPipeline(ctx, hash, cmds, tx)
if err != nil {
setCmdsErr(cmds, err)
}
_ = c.processShardPipeline(ctx, hash, cmds, tx)
}(hash, cmds)
}
@ -663,15 +660,14 @@ func (c *Ring) processShardPipeline(
//TODO: retry?
shard, err := c.shards.GetByHash(hash)
if err != nil {
setCmdsErr(cmds, err)
return err
}
if tx {
err = shard.Client._generalProcessPipeline(
ctx, cmds, shard.Client.txPipelineProcessCmds)
err = shard.Client.processPipeline(ctx, cmds)
} else {
err = shard.Client._generalProcessPipeline(
ctx, cmds, shard.Client.pipelineProcessCmds)
err = shard.Client.processTxPipeline(ctx, cmds)
}
return err
}