From 6307b9503901a1b01e73c03f7cecb74bef18b45c Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Tue, 9 May 2017 12:44:36 +0300 Subject: [PATCH] Export Cmder.Name --- cluster.go | 2 +- command.go | 8 ++++---- ring.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cluster.go b/cluster.go index 5c2e59f..99d8d7d 100644 --- a/cluster.go +++ b/cluster.go @@ -392,7 +392,7 @@ func (c *ClusterClient) cmdSlotAndNode(state *clusterState, cmd Cmder) (int, *cl return 0, node, err } - cmdInfo := c.cmds[cmd.name()] + cmdInfo := c.cmds[cmd.Name()] firstKey := cmd.arg(cmdFirstKeyPos(cmd, cmdInfo)) slot := hashtag.Slot(firstKey) diff --git a/command.go b/command.go index 33c11aa..361661a 100644 --- a/command.go +++ b/command.go @@ -33,7 +33,7 @@ var ( type Cmder interface { args() []interface{} arg(int) string - name() string + Name() string readReply(*pool.Conn) error setErr(error) @@ -84,7 +84,7 @@ func cmdString(cmd Cmder, val interface{}) string { } func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int { - switch cmd.name() { + switch cmd.Name() { case "eval", "evalsha": if cmd.arg(2) != "0" { return 3 @@ -95,7 +95,7 @@ func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int { return 1 } if info == nil { - internal.Logf("info for cmd=%s not found", cmd.name()) + internal.Logf("info for cmd=%s not found", cmd.Name()) return -1 } return int(info.FirstKeyPos) @@ -126,7 +126,7 @@ func (cmd *baseCmd) arg(pos int) string { return s } -func (cmd *baseCmd) name() string { +func (cmd *baseCmd) Name() string { if len(cmd._args) > 0 { // Cmd name must be lower cased. s := internal.ToLower(cmd.arg(0)) diff --git a/ring.go b/ring.go index c190b28..270a81f 100644 --- a/ring.go +++ b/ring.go @@ -298,7 +298,7 @@ func (c *Ring) shardByName(name string) (*ringShard, error) { } func (c *Ring) cmdShard(cmd Cmder) (*ringShard, error) { - cmdInfo := c.cmdInfo(cmd.name()) + cmdInfo := c.cmdInfo(cmd.Name()) firstKey := cmd.arg(cmdFirstKeyPos(cmd, cmdInfo)) return c.shardByKey(firstKey) } @@ -397,7 +397,7 @@ func (c *Ring) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) { func (c *Ring) pipelineExec(cmds []Cmder) (firstErr error) { cmdsMap := make(map[string][]Cmder) for _, cmd := range cmds { - cmdInfo := c.cmdInfo(cmd.name()) + cmdInfo := c.cmdInfo(cmd.Name()) name := cmd.arg(cmdFirstKeyPos(cmd, cmdInfo)) if name != "" { name = c.hash.Get(hashtag.Key(name))