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,25 +33,28 @@ type PostPingMeta struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PostTxBeginMeta struct {
|
type PostTxBeginMeta struct {
|
||||||
Init time.Time
|
ConstructorContext context.Context
|
||||||
Start time.Time
|
Init time.Time
|
||||||
End time.Time
|
Start time.Time
|
||||||
|
End time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostTxCommitMeta struct {
|
type PostTxCommitMeta struct {
|
||||||
Init time.Time
|
ConstructorContext context.Context
|
||||||
Start time.Time
|
Init time.Time
|
||||||
End time.Time
|
Start time.Time
|
||||||
ExecCounter int
|
End time.Time
|
||||||
QueryCounter int
|
ExecCounter int
|
||||||
|
QueryCounter int
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostTxRollbackMeta struct {
|
type PostTxRollbackMeta struct {
|
||||||
Init time.Time
|
ConstructorContext context.Context
|
||||||
Start time.Time
|
Init time.Time
|
||||||
End time.Time
|
Start time.Time
|
||||||
ExecCounter int
|
End time.Time
|
||||||
QueryCounter int
|
ExecCounter int
|
||||||
|
QueryCounter int
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostQueryMeta struct {
|
type PostQueryMeta struct {
|
||||||
|
@ -27,22 +27,24 @@ type Tx interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type transaction struct {
|
type transaction struct {
|
||||||
tx *sqlx.Tx
|
constructorContext context.Context
|
||||||
id uint16
|
tx *sqlx.Tx
|
||||||
status TxStatus
|
id uint16
|
||||||
execCtr int
|
status TxStatus
|
||||||
queryCtr int
|
execCtr int
|
||||||
db *database
|
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{
|
return &transaction{
|
||||||
tx: xtx,
|
constructorContext: ctx,
|
||||||
id: txid,
|
tx: xtx,
|
||||||
status: TxStatusInitial,
|
id: txid,
|
||||||
execCtr: 0,
|
status: TxStatusInitial,
|
||||||
queryCtr: 0,
|
execCtr: 0,
|
||||||
db: db,
|
queryCtr: 0,
|
||||||
|
db: db,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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