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