Merge pull request #6181 from steven-zou/add_test_on_borrow_func

Add TestOnBorrow check func of redis pool to verify the getting conn
This commit is contained in:
Steven Zou 2018-10-31 14:10:33 +08:00 committed by GitHub
commit 646cf282ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,