pulled functions out of New()
This commit is contained in:
parent
2759dd6e2f
commit
7d99b0ea9e
1 changed files with 37 additions and 31 deletions
|
@ -21,7 +21,14 @@ func (d *driver) New(conf *config.Storage) (storage.Conn, error) {
|
|||
pool: &redis.Pool{
|
||||
MaxIdle: 3,
|
||||
IdleTimeout: 240 * time.Second,
|
||||
Dial: func() (redis.Conn, error) {
|
||||
Dial: makeDialFunc(conf),
|
||||
TestOnBorrow: testOnBorrow,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func makeDialFunc(conf *config.Storage) func() (redis.Conn, error) {
|
||||
return func() (redis.Conn, error) {
|
||||
var (
|
||||
conn redis.Conn
|
||||
err error
|
||||
|
@ -45,13 +52,12 @@ func (d *driver) New(conf *config.Storage) (storage.Conn, error) {
|
|||
return nil, err
|
||||
}
|
||||
return conn, nil
|
||||
},
|
||||
TestOnBorrow: func(c redis.Conn, t time.Time) error {
|
||||
}
|
||||
}
|
||||
|
||||
func testOnBorrow(c redis.Conn, t time.Time) error {
|
||||
_, err := c.Do("PING")
|
||||
return err
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
type Conn struct {
|
||||
|
|
Loading…
Add table
Reference in a new issue