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

Method getConnection

IceFireDB-SQLProxy/pkg/mysql/client/pool.go:199–218  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

197}
198
199func (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
220func (pool *Pool) putConnectionUnsafe(connection Connection) {
221 if len(pool.synchro.idleConnections) == cap(pool.synchro.idleConnections) {

Callers 1

GetConnMethod · 0.95

Calls 2

DoneMethod · 0.80

Tested by

no test coverage detected