Skip to content

Commit

Permalink
Make readOnly a private field so that only cluster client can use it
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjun.yan committed Jul 25, 2017
1 parent e8e77ae commit 4e1d2a0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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()
}

Expand Down
6 changes: 2 additions & 4 deletions universal.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ type UniversalOptions struct {
// Only single-node and failover clients.
DB int

// Only cluster clients.

// Enables read only queries on slave nodes.
// Only cluster and single-node clients.
ReadOnly bool

// Only cluster clients.

MaxRedirects int
RouteByLatency bool

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4e1d2a0

Please sign in to comment.