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

Method GetConn

IceFireDB-SQLite/pkg/mysql/client/pool.go:145–162  ·  view source on GitHub ↗

GetConn returns connection from the pool or create new

(ctx context.Context)

Source from the content-addressed store, hash-verified

143
144// GetConn returns connection from the pool or create new
145func (pool *Pool) GetConn(ctx context.Context) (*Conn, error) {
146 for {
147 connection, err := pool.getConnection(ctx)
148 if err != nil {
149 return nil, err
150 }
151
152 // For long time idle connections, we do a ping check
153 if delta := pool.nowTs() - connection.lastUseAt; delta > pool.idlePingTimeout {
154 if err := pool.ping(connection.conn); err != nil {
155 pool.closeConn(connection.conn)
156 continue
157 }
158 }
159
160 return connection.conn, nil
161 }
162}
163
164// PutConn returns working connection back to pool
165func (pool *Pool) PutConn(conn *Conn) {

Callers

nothing calls this directly

Calls 4

getConnectionMethod · 0.95
nowTsMethod · 0.95
pingMethod · 0.95
closeConnMethod · 0.95

Tested by

no test coverage detected