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

Method GetConn

IceFireDB-SQLProxy/pkg/mysql/client/pool.go:147–164  ·  view source on GitHub ↗

GetConn returns connection from the pool or create new

(ctx context.Context)

Source from the content-addressed store, hash-verified

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

Callers 1

popConnMethod · 0.45

Calls 4

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

Tested by

no test coverage detected