mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-23 17:47:29 +00:00
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{
|
pool: &redis.Pool{
|
||||||
MaxIdle: 3,
|
MaxIdle: 3,
|
||||||
IdleTimeout: 240 * time.Second,
|
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 (
|
var (
|
||||||
conn redis.Conn
|
conn redis.Conn
|
||||||
err error
|
err error
|
||||||
|
@ -45,13 +52,12 @@ func (d *driver) New(conf *config.Storage) (storage.Conn, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return conn, nil
|
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")
|
_, err := c.Do("PING")
|
||||||
return err
|
return err
|
||||||
},
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Conn struct {
|
type Conn struct {
|
||||||
|
|
Loading…
Add table
Reference in a new issue