1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Embed Cmdable into StatefulCmdable

This commit is contained in:
Vladimir Mihailenco
2017-05-25 13:38:04 +03:00
parent 368f0ea0ba
commit 7e8890b644
7 changed files with 23 additions and 23 deletions

View File

@ -238,6 +238,7 @@ type Cmdable interface {
}
type StatefulCmdable interface {
Cmdable
Auth(password string) *StatusCmd
Select(index int) *StatusCmd
ClientSetName(name string) *BoolCmd
@ -255,10 +256,20 @@ type cmdable struct {
process func(cmd Cmder) error
}
func (c *cmdable) setProcessor(fn func(Cmder) error) {
c.process = fn
}
type statefulCmdable struct {
cmdable
process func(cmd Cmder) error
}
func (c *statefulCmdable) setProcessor(fn func(Cmder) error) {
c.process = fn
c.cmdable.setProcessor(fn)
}
//------------------------------------------------------------------------------
func (c *statefulCmdable) Auth(password string) *StatusCmd {
@ -280,7 +291,6 @@ func (c *cmdable) Ping() *StatusCmd {
}
func (c *cmdable) Wait(numSlaves int, timeout time.Duration) *IntCmd {
cmd := NewIntCmd("wait", numSlaves, int(timeout/time.Millisecond))
c.process(cmd)
return cmd