mirror of
https://github.com/redis/go-redis.git
synced 2025-07-31 05:04:23 +03:00
Use a lock-free connection pool
This commit is contained in:
10
sentinel.go
10
sentinel.go
@ -23,6 +23,7 @@ type FailoverOptions struct {
|
||||
DialTimeout time.Duration
|
||||
ReadTimeout time.Duration
|
||||
WriteTimeout time.Duration
|
||||
PoolTimeout time.Duration
|
||||
IdleTimeout time.Duration
|
||||
}
|
||||
|
||||
@ -33,6 +34,13 @@ func (opt *FailoverOptions) getPoolSize() int {
|
||||
return opt.PoolSize
|
||||
}
|
||||
|
||||
func (opt *FailoverOptions) getPoolTimeout() time.Duration {
|
||||
if opt.PoolTimeout == 0 {
|
||||
return 5 * time.Second
|
||||
}
|
||||
return opt.PoolTimeout
|
||||
}
|
||||
|
||||
func (opt *FailoverOptions) getDialTimeout() time.Duration {
|
||||
if opt.DialTimeout == 0 {
|
||||
return 5 * time.Second
|
||||
@ -50,6 +58,7 @@ func (opt *FailoverOptions) options() *options {
|
||||
WriteTimeout: opt.WriteTimeout,
|
||||
|
||||
PoolSize: opt.getPoolSize(),
|
||||
PoolTimeout: opt.getPoolTimeout(),
|
||||
IdleTimeout: opt.IdleTimeout,
|
||||
}
|
||||
}
|
||||
@ -169,6 +178,7 @@ func (d *sentinelFailover) MasterAddr() (string, error) {
|
||||
WriteTimeout: d.opt.WriteTimeout,
|
||||
|
||||
PoolSize: d.opt.PoolSize,
|
||||
PoolTimeout: d.opt.PoolTimeout,
|
||||
IdleTimeout: d.opt.IdleTimeout,
|
||||
})
|
||||
masterAddr, err := sentinel.GetMasterAddrByName(d.masterName).Result()
|
||||
|
Reference in New Issue
Block a user