From 4e1d2a01db8ebcec6ddeae623050cbaa7df5ffcf Mon Sep 17 00:00:00 2001 From: "wenjun.yan" Date: Tue, 25 Jul 2017 10:35:41 +0900 Subject: [PATCH] Make readOnly a private field so that only cluster client can use it --- cluster.go | 2 +- options.go | 2 +- redis.go | 4 ++-- universal.go | 8 +++----- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cluster.go b/cluster.go index 30c5ce64..a8695c32 100644 --- a/cluster.go +++ b/cluster.go @@ -88,7 +88,7 @@ func (opt *ClusterOptions) clientOptions() *Options { MinRetryBackoff: opt.MinRetryBackoff, MaxRetryBackoff: opt.MaxRetryBackoff, Password: opt.Password, - ReadOnly: opt.ReadOnly, + readOnly: opt.ReadOnly, DialTimeout: opt.DialTimeout, ReadTimeout: opt.ReadTimeout, diff --git a/options.go b/options.go index efa8f6aa..dea04545 100644 --- a/options.go +++ b/options.go @@ -73,7 +73,7 @@ type Options struct { IdleCheckFrequency time.Duration // Enables read only queries on slave nodes. - ReadOnly bool + readOnly bool // TLS Config to use. When set TLS will be negotiated. TLSConfig *tls.Config diff --git a/redis.go b/redis.go index b3a215e4..b18973cd 100644 --- a/redis.go +++ b/redis.go @@ -68,7 +68,7 @@ func (c *baseClient) initConn(cn *pool.Conn) error { if c.opt.Password == "" && c.opt.DB == 0 && - !c.opt.ReadOnly && + !c.opt.readOnly && c.opt.OnConnect == nil { return nil } @@ -91,7 +91,7 @@ func (c *baseClient) initConn(cn *pool.Conn) error { pipe.Select(c.opt.DB) } - if c.opt.ReadOnly { + if c.opt.readOnly { pipe.ReadOnly() } diff --git a/universal.go b/universal.go index 02ed51ab..4aa579fa 100644 --- a/universal.go +++ b/universal.go @@ -17,12 +17,11 @@ type UniversalOptions struct { // Only single-node and failover clients. DB int - // Enables read only queries on slave nodes. - // Only cluster and single-node clients. - ReadOnly bool - // Only cluster clients. + // Enables read only queries on slave nodes. + ReadOnly bool + MaxRedirects int RouteByLatency bool @@ -93,7 +92,6 @@ func (o *UniversalOptions) simple() *Options { return &Options{ Addr: addr, DB: o.DB, - ReadOnly: o.ReadOnly, MaxRetries: o.MaxRetries, Password: o.Password,