|
|
@ -61,18 +61,16 @@ func NewPool(c *Config, options ...DialOption) (p *Pool) { |
|
|
|
if c.DialTimeout <= 0 || c.ReadTimeout <= 0 || c.WriteTimeout <= 0 { |
|
|
|
if c.DialTimeout <= 0 || c.ReadTimeout <= 0 || c.WriteTimeout <= 0 { |
|
|
|
panic("must config redis timeout") |
|
|
|
panic("must config redis timeout") |
|
|
|
} |
|
|
|
} |
|
|
|
p1 := pool.NewSlice(c.Config) |
|
|
|
var ops []DialOption |
|
|
|
cnop := DialConnectTimeout(time.Duration(c.DialTimeout)) |
|
|
|
cnop := DialConnectTimeout(time.Duration(c.DialTimeout)) |
|
|
|
options = append(options, cnop) |
|
|
|
|
|
|
|
rdop := DialReadTimeout(time.Duration(c.ReadTimeout)) |
|
|
|
rdop := DialReadTimeout(time.Duration(c.ReadTimeout)) |
|
|
|
options = append(options, rdop) |
|
|
|
|
|
|
|
wrop := DialWriteTimeout(time.Duration(c.WriteTimeout)) |
|
|
|
wrop := DialWriteTimeout(time.Duration(c.WriteTimeout)) |
|
|
|
options = append(options, wrop) |
|
|
|
|
|
|
|
auop := DialPassword(c.Auth) |
|
|
|
auop := DialPassword(c.Auth) |
|
|
|
options = append(options, auop) |
|
|
|
ops = append(ops, cnop, rdop, wrop, auop) |
|
|
|
// new pool
|
|
|
|
ops = append(ops, options...) |
|
|
|
|
|
|
|
p1 := pool.NewSlice(c.Config) |
|
|
|
p1.New = func(ctx context.Context) (io.Closer, error) { |
|
|
|
p1.New = func(ctx context.Context) (io.Closer, error) { |
|
|
|
conn, err := Dial(c.Proto, c.Addr, options...) |
|
|
|
conn, err := Dial(c.Proto, c.Addr, ops...) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|