micro-wrapper-sql/tx.go
Vasiliy Tolstov b2eb8e6c5c complete meter
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-05 16:03:21 +03:00

33 lines
533 B
Go

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()
}
err := w.tx.Commit()
return err
}
// Rollback implements driver.Tx Rollback
func (w *wrapperTx) Rollback() error {
if w.span != nil {
defer w.span.Finish()
}
err := w.tx.Rollback()
return err
}