mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-12 19:00:50 +01:00
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:
commit
646cf282ba
@ -192,6 +192,14 @@ func (bs *Bootstrap) loadAndRunRedisWorkerPool(ctx *env.Context, cfg *config.Con
|
|||||||
redis.DialWriteTimeout(dialWriteTimeout),
|
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,
|
redisWorkerPool := pool.NewGoCraftWorkPool(ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user