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:
parent
f6b47792a4
commit
dc6cb274ee
@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.518"
|
const GoextVersion = "0.0.519"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-10-05T00:45:55+0200"
|
const GoextVersionTimestamp = "2024-10-05T00:58:15+0200"
|
||||||
|
@ -172,7 +172,7 @@ func (db *database) BeginTransaction(ctx context.Context, iso sql.IsolationLevel
|
|||||||
return nil, exerr.Wrap(err, "Failed to start sql transaction").Build()
|
return nil, exerr.Wrap(err, "Failed to start sql transaction").Build()
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewTransaction(xtx, txid, db), nil
|
return newTransaction(ctx, xtx, txid, db), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *database) Exit() error {
|
func (db *database) Exit() error {
|
||||||
|
@ -9,12 +9,15 @@ type PrePingMeta struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PreTxBeginMeta struct {
|
type PreTxBeginMeta struct {
|
||||||
|
ConstructorContext context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
type PreTxCommitMeta struct {
|
type PreTxCommitMeta struct {
|
||||||
|
ConstructorContext context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
type PreTxRollbackMeta struct {
|
type PreTxRollbackMeta struct {
|
||||||
|
ConstructorContext context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
type PreQueryMeta struct {
|
type PreQueryMeta struct {
|
||||||
@ -30,12 +33,14 @@ type PostPingMeta struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PostTxBeginMeta struct {
|
type PostTxBeginMeta struct {
|
||||||
|
ConstructorContext context.Context
|
||||||
Init time.Time
|
Init time.Time
|
||||||
Start time.Time
|
Start time.Time
|
||||||
End time.Time
|
End time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostTxCommitMeta struct {
|
type PostTxCommitMeta struct {
|
||||||
|
ConstructorContext context.Context
|
||||||
Init time.Time
|
Init time.Time
|
||||||
Start time.Time
|
Start time.Time
|
||||||
End time.Time
|
End time.Time
|
||||||
@ -44,6 +49,7 @@ type PostTxCommitMeta struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PostTxRollbackMeta struct {
|
type PostTxRollbackMeta struct {
|
||||||
|
ConstructorContext context.Context
|
||||||
Init time.Time
|
Init time.Time
|
||||||
Start time.Time
|
Start time.Time
|
||||||
End time.Time
|
End time.Time
|
||||||
|
@ -27,6 +27,7 @@ type Tx interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type transaction struct {
|
type transaction struct {
|
||||||
|
constructorContext context.Context
|
||||||
tx *sqlx.Tx
|
tx *sqlx.Tx
|
||||||
id uint16
|
id uint16
|
||||||
status TxStatus
|
status TxStatus
|
||||||
@ -35,8 +36,9 @@ type transaction struct {
|
|||||||
db *database
|
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{
|
return &transaction{
|
||||||
|
constructorContext: ctx,
|
||||||
tx: xtx,
|
tx: xtx,
|
||||||
id: txid,
|
id: txid,
|
||||||
status: TxStatusInitial,
|
status: TxStatusInitial,
|
||||||
@ -50,7 +52,7 @@ func (tx *transaction) Rollback() error {
|
|||||||
|
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
|
|
||||||
preMeta := PreTxRollbackMeta{}
|
preMeta := PreTxRollbackMeta{ConstructorContext: tx.constructorContext}
|
||||||
for _, v := range tx.db.lstr {
|
for _, v := range tx.db.lstr {
|
||||||
err := v.PreTxRollback(tx.id, preMeta)
|
err := v.PreTxRollback(tx.id, preMeta)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -66,7 +68,7 @@ func (tx *transaction) Rollback() error {
|
|||||||
tx.status = TxStatusRollback
|
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 {
|
for _, v := range tx.db.lstr {
|
||||||
v.PostTxRollback(tx.id, result, postMeta)
|
v.PostTxRollback(tx.id, result, postMeta)
|
||||||
}
|
}
|
||||||
@ -78,7 +80,7 @@ func (tx *transaction) Commit() error {
|
|||||||
|
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
|
|
||||||
preMeta := PreTxCommitMeta{}
|
preMeta := PreTxCommitMeta{ConstructorContext: tx.constructorContext}
|
||||||
for _, v := range tx.db.lstr {
|
for _, v := range tx.db.lstr {
|
||||||
err := v.PreTxCommit(tx.id, preMeta)
|
err := v.PreTxCommit(tx.id, preMeta)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -94,7 +96,7 @@ func (tx *transaction) Commit() error {
|
|||||||
tx.status = TxStatusComitted
|
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 {
|
for _, v := range tx.db.lstr {
|
||||||
v.PostTxCommit(tx.id, result, postMeta)
|
v.PostTxCommit(tx.id, result, postMeta)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user