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

Method recheckConnections

IceFireDB-SQLProxy/pkg/mysql/client/pool.go:349–374  ·  view source on GitHub ↗
(connections []Connection)

Source from the content-addressed store, hash-verified

347}
348
349func (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
377func (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