(connections []Connection)
| 347 | } |
| 348 | |
| 349 | func (pool *Pool) recheckConnections(connections []Connection) { |
| 350 | const workerCnt = 2 // Heuristic :) |
| 351 | |
| 352 | queue := make(chan Connection, len(connections)) |
| 353 | for _, connection := range connections { |
| 354 | queue <- connection |
| 355 | } |
| 356 | close(queue) |
| 357 | |
| 358 | var wg sync.WaitGroup |
| 359 | wg.Add(workerCnt) |
| 360 | for worker := 0; worker < workerCnt; worker++ { |
| 361 | go func() { |
| 362 | defer wg.Done() |
| 363 | for connection := range queue { |
| 364 | if err := pool.ping(connection.conn); err != nil { |
| 365 | pool.closeConn(connection.conn) |
| 366 | } else { |
| 367 | pool.putConnection(connection) |
| 368 | } |
| 369 | } |
| 370 | }() |
| 371 | } |
| 372 | |
| 373 | wg.Wait() |
| 374 | } |
| 375 | |
| 376 | // spawnConnectionsIfNeeded creates new connections if there are not enough of them and returns true in this case |
| 377 | func (pool *Pool) spawnConnectionsIfNeeded() bool { |
no test coverage detected