From ab1e8de9ea33fe63e2de8467a4ee5a98ff3524f2 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 20 Mar 2017 12:15:21 +0200 Subject: [PATCH] Add ability to read client options --- cluster.go | 5 +++++ redis.go | 5 +++++ ring.go | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/cluster.go b/cluster.go index a5a16db7..7d7b0260 100644 --- a/cluster.go +++ b/cluster.go @@ -372,6 +372,11 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient { return c } +// Options returns read-only Options that were used to create the client. +func (c *ClusterClient) Options() *ClusterOptions { + return c.opt +} + func (c *ClusterClient) state() *clusterState { v := c._state.Load() if v != nil { diff --git a/redis.go b/redis.go index 1ddd754c..74d677b0 100644 --- a/redis.go +++ b/redis.go @@ -21,6 +21,11 @@ func (c *baseClient) String() string { return fmt.Sprintf("Redis<%s db:%d>", c.getAddr(), c.opt.DB) } +// Options returns read-only Options that were used to create the client. +func (c *baseClient) Options() *Options { + return c.opt +} + func (c *baseClient) conn() (*pool.Conn, bool, error) { cn, isNew, err := c.connPool.Get() if err != nil { diff --git a/ring.go b/ring.go index 6e5f62ae..9b03f97f 100644 --- a/ring.go +++ b/ring.go @@ -158,6 +158,11 @@ func NewRing(opt *RingOptions) *Ring { return ring } +// Options returns read-only Options that were used to create the client. +func (c *Ring) Options() *RingOptions { + return c.opt +} + // PoolStats returns accumulated connection pool stats. func (c *Ring) PoolStats() *PoolStats { var acc PoolStats