1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-10 00:29:01 +02:00

fix redis option order

This commit is contained in:
ericjwang 2019-07-02 22:56:38 +08:00
parent aad6ecf1b6
commit aeca8024f7

View File

@ -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
} }