From 0358ca4bfeb8022e11cf0ade3a791749b79f840a Mon Sep 17 00:00:00 2001 From: monkey92t Date: Thu, 29 Dec 2022 17:04:57 +0800 Subject: [PATCH] fix: hook.process.fn should return error instead of cmd.SetErr() Signed-off-by: monkey92t --- .gitignore | 2 +- cluster_commands.go | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index b975a7b..dc322f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *.rdb -testdata/*/ +testdata/* .idea/ diff --git a/cluster_commands.go b/cluster_commands.go index 085bce8..4406223 100644 --- a/cluster_commands.go +++ b/cluster_commands.go @@ -18,11 +18,12 @@ func (c *ClusterClient) DBSize(ctx context.Context) *IntCmd { atomic.AddInt64(&size, n) return nil }) + if err != nil { - cmd.SetErr(err) - } else { - cmd.val = size + return err } + + cmd.val = size return nil }) return cmd @@ -46,10 +47,8 @@ func (c *ClusterClient) ScriptLoad(ctx context.Context, script string) *StringCm return nil }) - if err != nil { - cmd.SetErr(err) - } - return nil + + return err }) return cmd } @@ -60,10 +59,8 @@ func (c *ClusterClient) ScriptFlush(ctx context.Context) *StatusCmd { err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error { return shard.ScriptFlush(ctx).Err() }) - if err != nil { - cmd.SetErr(err) - } - return nil + + return err }) return cmd } @@ -98,11 +95,12 @@ func (c *ClusterClient) ScriptExists(ctx context.Context, hashes ...string) *Boo return nil }) + if err != nil { - cmd.SetErr(err) - } else { - cmd.val = result + return err } + + cmd.val = result return nil }) return cmd