pulled functions out of New()

This commit is contained in:
Jimmy Zelinskie 2013-06-25 23:08:54 -04:00
parent 2759dd6e2f
commit 7d99b0ea9e

View file

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