diff --git a/README.md b/README.md index 60149d9..e1c2ce9 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ Package redisc implements a redis cluster client built on top of the [redigo pac ## Releases +* **v1.1.4** : Add `Conn.DoWithTimeout` and `Conn.ReceiveWithTimeout` to match redigo's `ConnWithTimeout` interface (thanks to [@letsfire][letsfire]). + * **v1.1.3** : Fix handling of `ASK` replies in `RetryConn`. * **v1.1.2** : Remove mention that `StartupNodes` in `Cluster` struct needs to be master nodes (it can be replicas). Add supporting test. @@ -69,4 +71,4 @@ The [BSD 3-Clause license][bsd]. [rgc]: https://github.com/chasex/redis-go-cluster [radix1]: https://github.com/fzzy/radix [radix2]: https://github.com/mediocregopher/radix.v2 - +[letsfire]: https://github.com/letsfire diff --git a/conn.go b/conn.go index 0a07e5c..19cf3c1 100644 --- a/conn.go +++ b/conn.go @@ -11,7 +11,7 @@ import ( "github.com/gomodule/redigo/redis" ) -var _ redis.Conn = (*Conn)(nil) +var _ redis.ConnWithTimeout = (*Conn)(nil) // Conn is a redis cluster connection. When returned by Get // or Dial, it is not yet bound to any node in the cluster. @@ -236,9 +236,12 @@ func (c *Conn) Do(cmd string, args ...interface{}) (interface{}, error) { return c.DoWithTimeout(-1, cmd, args...) } -// Do sends a command to the server and returns the received reply. -// The timeout overrides the write timeout set when dialing the -// connection. +// DoWithTimeout sends a command to the server and returns the received reply. +// If the connection is not yet bound to a cluster node, it will be +// after this call, based on the rules documented in the Conn type. +// +// The timeout overrides the read timeout set when dialing the +// connection (in the DialOptions of the Cluster). func (c *Conn) DoWithTimeout(timeout time.Duration, cmd string, args ...interface{}) (v interface{}, err error) { rc, _, err := c.bind(cmdSlot(cmd, args)) if err != nil { @@ -278,8 +281,12 @@ func (c *Conn) Receive() (interface{}, error) { return c.ReceiveWithTimeout(-1) } -// Receive receives a single reply from the Redis server. The timeout -// overrides the read timeout set when dialing the connection. +// ReceiveWithTimeout receives a single reply from the Redis server. +// If the connection is not yet bound to a cluster node, it will be +// after this call, based on the rules documented in the Conn type. +// +// The timeout overrides the read timeout set when dialing the +// connection (in the DialOptions of the Cluster). func (c *Conn) ReceiveWithTimeout(timeout time.Duration) (v interface{}, err error) { rc, _, err := c.bind(-1) if err != nil { diff --git a/doc.go b/doc.go index d62922d..e9075b0 100644 --- a/doc.go +++ b/doc.go @@ -18,7 +18,8 @@ // for a redis.Pool from the redigo package. // // Similarly, the Conn type implements redigo's redis.Conn -// interface, so the API to execute commands is the same - +// interface (and the augmented redis.ConnWithTimeout one too), +// so the API to execute commands is the same - // in fact the redisc package uses the redigo package as its // only third-party dependency. // @@ -83,7 +84,8 @@ // Connection // // The connection returned from Get or Dial is a redigo redis.Conn -// interface, with a concrete type of *Conn. In addition to the +// interface (that also implements redis.ConnWithTimeout), +// with a concrete type of *Conn. In addition to the // interface's required methods, *Conn adds the following methods: // // Bind(...string) error