MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / BeginTx

Method BeginTx

inventory/debug/debug.go:94–108  ·  view source on GitHub ↗

BeginTx adds an log-id for the transaction and calls the underlying driver BeginTx command if it is supported.

(ctx context.Context, opts *sql.TxOptions)

Source from the content-addressed store, hash-verified

92
93// BeginTx adds an log-id for the transaction and calls the underlying driver BeginTx command if it is supported.
94func (d *DebugDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (dialect.Tx, error) {
95 drv, ok := d.Driver.(interface {
96 BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
97 })
98 if !ok {
99 return nil, fmt.Errorf("Driver.BeginTx is not supported")
100 }
101 tx, err := drv.BeginTx(ctx, opts)
102 if err != nil {
103 return nil, err
104 }
105 id := uuid.New().String()
106 d.log(ctx, fmt.Sprintf("driver.BeginTx(%s): started", id))
107 return &DebugTx{tx, id, d.log, ctx}, nil
108}
109
110// DebugTx is a transaction implementation that logs all transaction operations.
111type DebugTx struct {

Callers

nothing calls this directly

Calls 2

StringMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected