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

Method getConnection

IceFireDB-SQLite/pkg/mysql/client/pool.go:197–216  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

195}
196
197func (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
218func (pool *Pool) putConnectionUnsafe(connection Connection) {
219 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