performQueries tests the resource pool of connections.
(query int, p *pool.Pool)
| 75 | |
| 76 | // performQueries tests the resource pool of connections. |
| 77 | func performQueries(query int, p *pool.Pool) { |
| 78 | // Acquire a connection from the pool. |
| 79 | conn, err := p.Acquire() |
| 80 | if err != nil { |
| 81 | log.Println(err) |
| 82 | return |
| 83 | } |
| 84 | |
| 85 | // Release the connection back to the pool. |
| 86 | defer p.Release(conn) |
| 87 | |
| 88 | // Wait to simulate a query response. |
| 89 | time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond) |
| 90 | log.Printf("Query: QID[%d] CID[%d]\n", query, conn.(*dbConnection).ID) |
| 91 | } |