forked from mirror/redis
add option for sentinel password
This commit is contained in:
parent
90febb9820
commit
c6e879efe2
11
sentinel.go
11
sentinel.go
|
@ -27,8 +27,9 @@ type FailoverOptions struct {
|
||||||
|
|
||||||
OnConnect func(*Conn) error
|
OnConnect func(*Conn) error
|
||||||
|
|
||||||
Password string
|
Password string
|
||||||
DB int
|
SentinelPassword string
|
||||||
|
DB int
|
||||||
|
|
||||||
MaxRetries int
|
MaxRetries int
|
||||||
MinRetryBackoff time.Duration
|
MinRetryBackoff time.Duration
|
||||||
|
@ -82,6 +83,7 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
|
||||||
failover := &sentinelFailover{
|
failover := &sentinelFailover{
|
||||||
masterName: failoverOpt.MasterName,
|
masterName: failoverOpt.MasterName,
|
||||||
sentinelAddrs: failoverOpt.SentinelAddrs,
|
sentinelAddrs: failoverOpt.SentinelAddrs,
|
||||||
|
password: failoverOpt.SentinelPassword,
|
||||||
|
|
||||||
opt: opt,
|
opt: opt,
|
||||||
}
|
}
|
||||||
|
@ -275,7 +277,8 @@ func (c *SentinelClient) Remove(name string) *StringCmd {
|
||||||
type sentinelFailover struct {
|
type sentinelFailover struct {
|
||||||
sentinelAddrs []string
|
sentinelAddrs []string
|
||||||
|
|
||||||
opt *Options
|
opt *Options
|
||||||
|
password string
|
||||||
|
|
||||||
pool *pool.ConnPool
|
pool *pool.ConnPool
|
||||||
poolOnce sync.Once
|
poolOnce sync.Once
|
||||||
|
@ -334,6 +337,8 @@ func (c *sentinelFailover) masterAddr() (string, error) {
|
||||||
sentinel := NewSentinelClient(&Options{
|
sentinel := NewSentinelClient(&Options{
|
||||||
Addr: sentinelAddr,
|
Addr: sentinelAddr,
|
||||||
|
|
||||||
|
Password: c.password,
|
||||||
|
|
||||||
MaxRetries: c.opt.MaxRetries,
|
MaxRetries: c.opt.MaxRetries,
|
||||||
|
|
||||||
DialTimeout: c.opt.DialTimeout,
|
DialTimeout: c.opt.DialTimeout,
|
||||||
|
|
Loading…
Reference in New Issue