MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / recheckConnections

Method recheckConnections

IceFireDB-SQLite/pkg/mysql/client/pool.go:347–372  ·  view source on GitHub ↗
(connections []Connection)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

pingMethod · 0.95
closeConnMethod · 0.95
putConnectionMethod · 0.95
DoneMethod · 0.80

Tested by

no test coverage detected