Add TestOnBorrow check func of redis pool to verify the getting conn

Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
Steven Zou 2018-10-31 13:30:29 +08:00
parent b48748492e
commit 58eefb9c17

View File

@ -192,6 +192,14 @@ func (bs *Bootstrap) loadAndRunRedisWorkerPool(ctx *env.Context, cfg *config.Con
redis.DialWriteTimeout(dialWriteTimeout),
)
},
TestOnBorrow: func(c redis.Conn, t time.Time) error {
if time.Since(t) < time.Minute {
return nil
}
_, err := c.Do("PING")
return err
},
}
redisWorkerPool := pool.NewGoCraftWorkPool(ctx,