mirror of https://github.com/go-redis/redis.git
Merge pull request #604 from v2e4lisp/fix/cluster-readonly
Limit Readonly Option to cluster client only
This commit is contained in:
commit
2fb3f0e45f
|
@ -88,7 +88,7 @@ func (opt *ClusterOptions) clientOptions() *Options {
|
||||||
MinRetryBackoff: opt.MinRetryBackoff,
|
MinRetryBackoff: opt.MinRetryBackoff,
|
||||||
MaxRetryBackoff: opt.MaxRetryBackoff,
|
MaxRetryBackoff: opt.MaxRetryBackoff,
|
||||||
Password: opt.Password,
|
Password: opt.Password,
|
||||||
ReadOnly: opt.ReadOnly,
|
readOnly: opt.ReadOnly,
|
||||||
|
|
||||||
DialTimeout: opt.DialTimeout,
|
DialTimeout: opt.DialTimeout,
|
||||||
ReadTimeout: opt.ReadTimeout,
|
ReadTimeout: opt.ReadTimeout,
|
||||||
|
|
|
@ -73,7 +73,7 @@ type Options struct {
|
||||||
IdleCheckFrequency time.Duration
|
IdleCheckFrequency time.Duration
|
||||||
|
|
||||||
// Enables read only queries on slave nodes.
|
// Enables read only queries on slave nodes.
|
||||||
ReadOnly bool
|
readOnly bool
|
||||||
|
|
||||||
// TLS Config to use. When set TLS will be negotiated.
|
// TLS Config to use. When set TLS will be negotiated.
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
|
|
4
redis.go
4
redis.go
|
@ -68,7 +68,7 @@ func (c *baseClient) initConn(cn *pool.Conn) error {
|
||||||
|
|
||||||
if c.opt.Password == "" &&
|
if c.opt.Password == "" &&
|
||||||
c.opt.DB == 0 &&
|
c.opt.DB == 0 &&
|
||||||
!c.opt.ReadOnly &&
|
!c.opt.readOnly &&
|
||||||
c.opt.OnConnect == nil {
|
c.opt.OnConnect == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ func (c *baseClient) initConn(cn *pool.Conn) error {
|
||||||
pipe.Select(c.opt.DB)
|
pipe.Select(c.opt.DB)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.opt.ReadOnly {
|
if c.opt.readOnly {
|
||||||
pipe.ReadOnly()
|
pipe.ReadOnly()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,11 @@ type UniversalOptions struct {
|
||||||
// Only single-node and failover clients.
|
// Only single-node and failover clients.
|
||||||
DB int
|
DB int
|
||||||
|
|
||||||
// Enables read only queries on slave nodes.
|
|
||||||
// Only cluster and single-node clients.
|
|
||||||
ReadOnly bool
|
|
||||||
|
|
||||||
// Only cluster clients.
|
// Only cluster clients.
|
||||||
|
|
||||||
|
// Enables read only queries on slave nodes.
|
||||||
|
ReadOnly bool
|
||||||
|
|
||||||
MaxRedirects int
|
MaxRedirects int
|
||||||
RouteByLatency bool
|
RouteByLatency bool
|
||||||
|
|
||||||
|
@ -93,7 +92,6 @@ func (o *UniversalOptions) simple() *Options {
|
||||||
return &Options{
|
return &Options{
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
DB: o.DB,
|
DB: o.DB,
|
||||||
ReadOnly: o.ReadOnly,
|
|
||||||
|
|
||||||
MaxRetries: o.MaxRetries,
|
MaxRetries: o.MaxRetries,
|
||||||
Password: o.Password,
|
Password: o.Password,
|
||||||
|
|
Loading…
Reference in New Issue