MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / doInTx

Method doInTx

plugins/destination/mssql/client/transaction.go:10–27  ·  view source on GitHub ↗
(ctx context.Context, op txOp)

Source from the content-addressed store, hash-verified

8type txOp func(tx *sql.Tx) error
9
10func (c *Client) doInTx(ctx context.Context, op txOp) (err error) {
11 tx, err := c.db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable})
12 if err != nil {
13 return err
14 }
15 defer func() {
16 if err == nil {
17 err = tx.Commit()
18 }
19 // also handles tx.Commit() err
20 if err != nil {
21 c.logErr(err)
22 _ = tx.Rollback()
23 }
24 }()
25
26 return op(tx)
27}

Callers 5

DeleteStaleMethod · 0.95
execStatementsMethod · 0.95
ReadMethod · 0.95
insertTVPMethod · 0.95
WriteTableBatchMethod · 0.95

Calls 1

logErrMethod · 0.95

Tested by

no test coverage detected