From 34122bffa897df4d7bf01cbd67e2e9d3f120e20c Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Wed, 14 Dec 2016 12:12:50 +0200 Subject: [PATCH] Check that clients implement scripter interface. --- cluster.go | 2 -- commands.go | 5 +++++ redis.go | 2 -- ring.go | 2 -- script.go | 4 ++++ tx.go | 2 -- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cluster.go b/cluster.go index f9a4fefb..0feebb48 100644 --- a/cluster.go +++ b/cluster.go @@ -328,8 +328,6 @@ type ClusterClient struct { closed bool } -var _ Cmdable = (*ClusterClient)(nil) - // NewClusterClient returns a Redis Cluster client as described in // http://redis.io/topics/cluster-spec. func NewClusterClient(opt *ClusterOptions) *ClusterClient { diff --git a/commands.go b/commands.go index 0f06652d..5132a597 100644 --- a/commands.go +++ b/commands.go @@ -236,6 +236,11 @@ type Cmdable interface { Command() *CommandsInfoCmd } +var _ Cmdable = (*Client)(nil) +var _ Cmdable = (*Tx)(nil) +var _ Cmdable = (*Ring)(nil) +var _ Cmdable = (*ClusterClient)(nil) + type cmdable struct { process func(cmd Cmder) error } diff --git a/redis.go b/redis.go index 6fcd5c4a..bf465172 100644 --- a/redis.go +++ b/redis.go @@ -172,8 +172,6 @@ type Client struct { cmdable } -var _ Cmdable = (*Client)(nil) - func newClient(opt *Options, pool pool.Pooler) *Client { base := baseClient{opt: opt, connPool: pool} client := &Client{ diff --git a/ring.go b/ring.go index 11945b4a..96f7294c 100644 --- a/ring.go +++ b/ring.go @@ -136,8 +136,6 @@ type Ring struct { closed bool } -var _ Cmdable = (*Ring)(nil) - func NewRing(opt *RingOptions) *Ring { const nreplicas = 100 opt.init() diff --git a/script.go b/script.go index c5fc1d2b..e569af7b 100644 --- a/script.go +++ b/script.go @@ -14,6 +14,10 @@ type scripter interface { ScriptLoad(script string) *StringCmd } +var _ scripter = (*Client)(nil) +var _ scripter = (*Ring)(nil) +var _ scripter = (*ClusterClient)(nil) + type Script struct { src, hash string } diff --git a/tx.go b/tx.go index 30beda94..c3503255 100644 --- a/tx.go +++ b/tx.go @@ -23,8 +23,6 @@ type Tx struct { closed bool } -var _ Cmdable = (*Tx)(nil) - func (c *Client) newTx() *Tx { tx := Tx{ baseClient: baseClient{