2021-10-27 18:49:33 +03:00
|
|
|
package wrapper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql/driver"
|
|
|
|
|
|
|
|
"go.unistack.org/micro/v3/tracer"
|
|
|
|
)
|
|
|
|
|
|
|
|
// wrapperTx defines a wrapper for driver.Tx
|
|
|
|
type wrapperTx struct {
|
|
|
|
tx driver.Tx
|
|
|
|
span tracer.Span
|
|
|
|
opts Options
|
|
|
|
}
|
|
|
|
|
|
|
|
// Commit implements driver.Tx Commit
|
|
|
|
func (w *wrapperTx) Commit() error {
|
|
|
|
if w.span != nil {
|
|
|
|
defer w.span.Finish()
|
|
|
|
}
|
2023-01-05 16:03:21 +03:00
|
|
|
err := w.tx.Commit()
|
|
|
|
return err
|
2021-10-27 18:49:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Rollback implements driver.Tx Rollback
|
|
|
|
func (w *wrapperTx) Rollback() error {
|
|
|
|
if w.span != nil {
|
|
|
|
defer w.span.Finish()
|
|
|
|
}
|
2023-01-05 16:03:21 +03:00
|
|
|
err := w.tx.Rollback()
|
|
|
|
return err
|
2021-10-27 18:49:33 +03:00
|
|
|
}
|