v0.0.519
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
This commit is contained in:
@@ -27,22 +27,24 @@ type Tx interface {
|
||||
}
|
||||
|
||||
type transaction struct {
|
||||
tx *sqlx.Tx
|
||||
id uint16
|
||||
status TxStatus
|
||||
execCtr int
|
||||
queryCtr int
|
||||
db *database
|
||||
constructorContext context.Context
|
||||
tx *sqlx.Tx
|
||||
id uint16
|
||||
status TxStatus
|
||||
execCtr int
|
||||
queryCtr int
|
||||
db *database
|
||||
}
|
||||
|
||||
func NewTransaction(xtx *sqlx.Tx, txid uint16, db *database) Tx {
|
||||
func newTransaction(ctx context.Context, xtx *sqlx.Tx, txid uint16, db *database) Tx {
|
||||
return &transaction{
|
||||
tx: xtx,
|
||||
id: txid,
|
||||
status: TxStatusInitial,
|
||||
execCtr: 0,
|
||||
queryCtr: 0,
|
||||
db: db,
|
||||
constructorContext: ctx,
|
||||
tx: xtx,
|
||||
id: txid,
|
||||
status: TxStatusInitial,
|
||||
execCtr: 0,
|
||||
queryCtr: 0,
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +52,7 @@ func (tx *transaction) Rollback() error {
|
||||
|
||||
t0 := time.Now()
|
||||
|
||||
preMeta := PreTxRollbackMeta{}
|
||||
preMeta := PreTxRollbackMeta{ConstructorContext: tx.constructorContext}
|
||||
for _, v := range tx.db.lstr {
|
||||
err := v.PreTxRollback(tx.id, preMeta)
|
||||
if err != nil {
|
||||
@@ -66,7 +68,7 @@ func (tx *transaction) Rollback() error {
|
||||
tx.status = TxStatusRollback
|
||||
}
|
||||
|
||||
postMeta := PostTxRollbackMeta{Init: t0, Start: t1, End: time.Now(), ExecCounter: tx.execCtr, QueryCounter: tx.queryCtr}
|
||||
postMeta := PostTxRollbackMeta{ConstructorContext: tx.constructorContext, Init: t0, Start: t1, End: time.Now(), ExecCounter: tx.execCtr, QueryCounter: tx.queryCtr}
|
||||
for _, v := range tx.db.lstr {
|
||||
v.PostTxRollback(tx.id, result, postMeta)
|
||||
}
|
||||
@@ -78,7 +80,7 @@ func (tx *transaction) Commit() error {
|
||||
|
||||
t0 := time.Now()
|
||||
|
||||
preMeta := PreTxCommitMeta{}
|
||||
preMeta := PreTxCommitMeta{ConstructorContext: tx.constructorContext}
|
||||
for _, v := range tx.db.lstr {
|
||||
err := v.PreTxCommit(tx.id, preMeta)
|
||||
if err != nil {
|
||||
@@ -94,7 +96,7 @@ func (tx *transaction) Commit() error {
|
||||
tx.status = TxStatusComitted
|
||||
}
|
||||
|
||||
postMeta := PostTxCommitMeta{Init: t0, Start: t1, End: time.Now(), ExecCounter: tx.execCtr, QueryCounter: tx.queryCtr}
|
||||
postMeta := PostTxCommitMeta{ConstructorContext: tx.constructorContext, Init: t0, Start: t1, End: time.Now(), ExecCounter: tx.execCtr, QueryCounter: tx.queryCtr}
|
||||
for _, v := range tx.db.lstr {
|
||||
v.PostTxCommit(tx.id, result, postMeta)
|
||||
}
|
||||
|
Reference in New Issue
Block a user