Merge pull request #561 from go-redis/fix/cmd-name

Export Cmder.Name
This commit is contained in:
Vladimir Mihailenco 2017-05-09 12:54:15 +03:00 committed by GitHub
commit 171eaf3331
3 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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))

View File

@ -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))