(ctx context.Context)
| 197 | } |
| 198 | |
| 199 | func (pool *Pool) getConnection(ctx context.Context) (Connection, error) { |
| 200 | pool.synchro.Lock() |
| 201 | |
| 202 | connection := pool.getIdleConnectionUnsafe() |
| 203 | if connection.conn != nil { |
| 204 | pool.synchro.Unlock() |
| 205 | return connection, nil |
| 206 | } |
| 207 | pool.synchro.Unlock() |
| 208 | |
| 209 | // No idle connections are available |
| 210 | |
| 211 | select { |
| 212 | case connection := <-pool.readyConnection: |
| 213 | return connection, nil |
| 214 | |
| 215 | case <-ctx.Done(): |
| 216 | return Connection{}, ctx.Err() |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func (pool *Pool) putConnectionUnsafe(connection Connection) { |
| 221 | if len(pool.synchro.idleConnections) == cap(pool.synchro.idleConnections) { |
no test coverage detected