diff --git a/cluster.go b/cluster.go index 019a2d44..c83da6a4 100644 --- a/cluster.go +++ b/cluster.go @@ -895,7 +895,7 @@ func (c *ClusterClient) Pipeline() Pipeliner { } func (c *ClusterClient) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) { - return c.Pipeline().pipelined(fn) + return c.Pipeline().Pipelined(fn) } func (c *ClusterClient) pipelineExec(cmds []Cmder) error { @@ -1033,7 +1033,7 @@ func (c *ClusterClient) TxPipeline() Pipeliner { } func (c *ClusterClient) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error) { - return c.TxPipeline().pipelined(fn) + return c.TxPipeline().Pipelined(fn) } func (c *ClusterClient) txPipelineExec(cmds []Cmder) error { diff --git a/commands.go b/commands.go index 83b3824f..7f0000f3 100644 --- a/commands.go +++ b/commands.go @@ -42,6 +42,9 @@ type Cmdable interface { Pipeline() Pipeliner Pipelined(fn func(Pipeliner) error) ([]Cmder, error) + TxPipelined(fn func(Pipeliner) error) ([]Cmder, error) + TxPipeline() Pipeliner + ClientGetName() *StringCmd Echo(message interface{}) *StringCmd Ping() *StatusCmd diff --git a/pipeline.go b/pipeline.go index b66c0597..9349ef55 100644 --- a/pipeline.go +++ b/pipeline.go @@ -13,9 +13,7 @@ type Pipeliner interface { Process(cmd Cmder) error Close() error Discard() error - discard() error Exec() ([]Cmder, error) - pipelined(fn func(Pipeliner) error) ([]Cmder, error) } var _ Pipeliner = (*Pipeline)(nil) @@ -104,3 +102,11 @@ func (c *Pipeline) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) { func (c *Pipeline) Pipeline() Pipeliner { return c } + +func (c *Pipeline) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error) { + return c.pipelined(fn) +} + +func (c *Pipeline) TxPipeline() Pipeliner { + return c +} diff --git a/redis.go b/redis.go index 70a17530..615bf28d 100644 --- a/redis.go +++ b/redis.go @@ -361,7 +361,7 @@ func (c *Client) PoolStats() *PoolStats { } func (c *Client) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) { - return c.Pipeline().pipelined(fn) + return c.Pipeline().Pipelined(fn) } func (c *Client) Pipeline() Pipeliner { @@ -373,7 +373,7 @@ func (c *Client) Pipeline() Pipeliner { } func (c *Client) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error) { - return c.TxPipeline().pipelined(fn) + return c.TxPipeline().Pipelined(fn) } // TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC. @@ -425,7 +425,7 @@ type Conn struct { } func (c *Conn) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) { - return c.Pipeline().pipelined(fn) + return c.Pipeline().Pipelined(fn) } func (c *Conn) Pipeline() Pipeliner { @@ -437,7 +437,7 @@ func (c *Conn) Pipeline() Pipeliner { } func (c *Conn) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error) { - return c.TxPipeline().pipelined(fn) + return c.TxPipeline().Pipelined(fn) } // TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC. diff --git a/ring.go b/ring.go index 7b3d2d14..d558763b 100644 --- a/ring.go +++ b/ring.go @@ -436,7 +436,7 @@ func (c *Ring) Pipeline() Pipeliner { } func (c *Ring) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) { - return c.Pipeline().pipelined(fn) + return c.Pipeline().Pipelined(fn) } func (c *Ring) pipelineExec(cmds []Cmder) error { @@ -493,3 +493,11 @@ func (c *Ring) pipelineExec(cmds []Cmder) error { return firstCmdsErr(cmds) } + +func (c *Ring) TxPipeline() Pipeliner { + panic("not implemented") +} + +func (c *Ring) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error) { + panic("not implemented") +} diff --git a/tx.go b/tx.go index 93c295d9..11d5d5cb 100644 --- a/tx.go +++ b/tx.go @@ -91,5 +91,13 @@ func (c *Tx) Pipeline() Pipeliner { // TxFailedErr is returned. Otherwise Exec returns error of the first // failed command or nil. func (c *Tx) Pipelined(fn func(Pipeliner) error) ([]Cmder, error) { - return c.Pipeline().pipelined(fn) + return c.Pipeline().Pipelined(fn) +} + +func (c *Tx) TxPipelined(fn func(Pipeliner) error) ([]Cmder, error) { + return c.Pipelined(fn) +} + +func (c *Tx) TxPipeline() Pipeliner { + return c.Pipeline() } diff --git a/universal.go b/universal.go index 4aa579fa..29eb12b1 100644 --- a/universal.go +++ b/universal.go @@ -90,8 +90,8 @@ func (o *UniversalOptions) simple() *Options { } return &Options{ - Addr: addr, - DB: o.DB, + Addr: addr, + DB: o.DB, MaxRetries: o.MaxRetries, Password: o.Password, @@ -117,6 +117,9 @@ type UniversalClient interface { Close() error } +var _ UniversalClient = (*Client)(nil) +var _ UniversalClient = (*ClusterClient)(nil) + // NewUniversalClient returns a new multi client. The type of client returned depends // on the following three conditions: //