MCPcopy Create free account
hub / github.com/actiontech/dtle / CreateConns

Function CreateConns

driver/mysql/sql/sqlutils.go:148–172  ·  view source on GitHub ↗
(ctx context.Context, db *gosql.DB, count int)

Source from the content-addressed store, hash-verified

146}
147
148func CreateConns(ctx context.Context, db *gosql.DB, count int) ([]*Conn, error) {
149 conns := make([]*Conn, count)
150 for i := 0; i < count; i++ {
151 conn, err := db.Conn(ctx)
152 if err != nil {
153 return nil, err
154 }
155
156 originVal, err := GetSetWaitTimeout(conn)
157 if err != nil {
158 g.Logger.Warn("CreateConns. GetSetWaitTimeout. failed. error ignored", "err", err, "originVal", originVal)
159 }
160
161 _, err = conn.ExecContext(ctx, "SET @@session.foreign_key_checks = 0")
162 if err != nil {
163 return nil, err
164 }
165
166 conns[i] = &Conn{
167 DbMutex: &sync.Mutex{},
168 Db: conn,
169 }
170 }
171 return conns, nil
172}
173
174// RowToArray is a convenience function, typically not called directly, which maps a
175// single read database row into a NullString

Callers 1

initDBConnectionsMethod · 0.92

Calls 2

GetSetWaitTimeoutFunction · 0.85
ExecContextMethod · 0.80

Tested by

no test coverage detected