()
| 294 | } |
| 295 | |
| 296 | func (pool *Pool) closeOldIdleConnections() { |
| 297 | var toPing []Connection |
| 298 | |
| 299 | ticker := time.NewTicker(5 * time.Second) |
| 300 | |
| 301 | for range ticker.C { |
| 302 | toPing = pool.getOldIdleConnections(toPing[:0]) |
| 303 | if len(toPing) == 0 { |
| 304 | continue |
| 305 | } |
| 306 | pool.recheckConnections(toPing) |
| 307 | |
| 308 | if !pool.spawnConnectionsIfNeeded() { |
| 309 | pool.closeIdleConnectionsIfCan() |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | func (pool *Pool) getOldIdleConnections(dst []Connection) []Connection { |
| 315 | dst = dst[:0] |
no test coverage detected