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

Method popConn

IceFireDB-SQLProxy/internal/mysql/proxy.go:126–161  ·  view source on GitHub ↗
(pool *client.Pool)

Source from the content-addressed store, hash-verified

124}
125
126func (m *mysqlProxy) popConn(pool *client.Pool) (*client.Conn, error) {
127 var mysqlConn *client.Conn
128 var err error
129 for i := 0; i < GetConnRetry; i++ {
130 mysqlConn, err = pool.GetConn(m.ctx)
131 if err != nil {
132 continue
133 }
134 err = mysqlConn.Ping()
135 if err != nil {
136 continue
137 }
138
139 if mysqlConn.IsInTransaction() {
140 if err := mysqlConn.Rollback(); err != nil {
141 mysqlConn.Close()
142 continue
143 }
144 }
145 if !mysqlConn.IsAutoCommit() {
146 if err := mysqlConn.SetAutoCommit(true); err != nil {
147 mysqlConn.Close()
148 continue
149 }
150 }
151
152 if mysqlConn.GetCharset() != mysql.DEFAULT_CHARSET {
153 if err := mysqlConn.SetCharset(mysql.DEFAULT_CHARSET); err != nil {
154 mysqlConn.Close()
155 continue
156 }
157 }
158 break
159 }
160 return mysqlConn, nil
161}
162
163func (m *mysqlProxy) pushAdminConn(mysqlConn *client.Conn, err error) {
164 m.pushConn(mysqlConn, err, m.adminPool)

Callers 2

popAdminConnMethod · 0.95
popReadonlyConnMethod · 0.95

Calls 9

PingMethod · 0.95
IsInTransactionMethod · 0.95
RollbackMethod · 0.95
CloseMethod · 0.95
IsAutoCommitMethod · 0.95
SetAutoCommitMethod · 0.95
GetCharsetMethod · 0.95
SetCharsetMethod · 0.95
GetConnMethod · 0.45

Tested by

no test coverage detected