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:
12
commands.go
12
commands.go
@ -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
|
||||
|
Reference in New Issue
Block a user