-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction_run.go
40 lines (39 loc) · 1.24 KB
/
transaction_run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package dalgo2datastore
//// RunInTransaction starts new transaction
//var RunInTransaction = func(c context.Context, tx transaction, f func(tc context.Context) error) error {
// //if LoggingEnabled {
// // if tx. == nil {
// // log.Debugf(c, "gaedb.RunInTransaction(): starting transaction, opts=nil...")
// // } else {
// // log.Debugf(c, "gaedb.RunInTransaction(): starting transaction, opts=%+v...", *opts)
// // }
// //}
// attempt := 0
// fWrapped := func(c context.Context) (err error) {
// attempt++
// txCtx := dal.NewContextWithTransaction(c, tx)
// log.Debugf(c, "tx attempt #%d", attempt)
// if err = f(txCtx); err != nil {
// m := fmt.Sprintf("tx attempt #%d failed: ", attempt)
// if err == datastore.ErrConcurrentTransaction {
// log.Warningf(c, m+err.Error())
// } else {
// log.Errorf(c, m+err.Error())
// }
// }
// return
// }
// if err := dbRunInTransaction(c, fWrapped, &tx.datastoreTxOptions); err != nil {
// if LoggingEnabled {
// if strings.Contains(err.Error(), "nested transactions are not supported") {
// panic(err)
// }
// log.Errorf(c, errors.WithMessage(err, "transaction failed").Error())
// }
// return err
// }
// if LoggingEnabled {
// log.Debugf(c, "Transaction successful")
// }
// return nil
//}