Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Unified Diff: go/src/infra/gae/libs/gae/memory/context.go

Issue 1242043005: Improve memory implementation of gae to provide the full RawDatastore interface. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@port_broken_features
Patch Set: further simplification of CL Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: go/src/infra/gae/libs/gae/memory/context.go
diff --git a/go/src/infra/gae/libs/gae/memory/context.go b/go/src/infra/gae/libs/gae/memory/context.go
index 3c8e8b5a7201061874dd3f282a80054e60493c8a..09ca643050d62f370a2f065cac1392d8caf23211 100644
--- a/go/src/infra/gae/libs/gae/memory/context.go
+++ b/go/src/infra/gae/libs/gae/memory/context.go
@@ -19,7 +19,7 @@ type memContextObj interface {
applyTxn(c context.Context, m memContextObj)
endTxn()
- mkTxn(*gae.DSTransactionOptions) (memContextObj, error)
+ mkTxn(*gae.DSTransactionOptions) memContextObj
}
type memContext []memContextObj
@@ -62,16 +62,12 @@ func (m memContext) endTxn() {
}
}
-func (m memContext) mkTxn(o *gae.DSTransactionOptions) (memContextObj, error) {
+func (m memContext) mkTxn(o *gae.DSTransactionOptions) memContextObj {
ret := make(memContext, len(m))
for i, itm := range m {
- newItm, err := itm.mkTxn(o)
- if err != nil {
- return nil, err
- }
- ret[i] = newItm
+ ret[i] = itm.mkTxn(o)
}
- return ret, nil
+ return ret
}
func (m memContext) canApplyTxn(txnCtxObj memContextObj) bool {
@@ -140,10 +136,7 @@ var memContextKey memContextKeyType
func (d *dsImpl) RunInTransaction(f func(context.Context) error, o *gae.DSTransactionOptions) error {
curMC := cur(d.c)
- txnMC, err := curMC.mkTxn(o)
- if err != nil {
- return err
- }
+ txnMC := curMC.mkTxn(o)
defer func() {
txnMC.Lock()
@@ -152,7 +145,7 @@ func (d *dsImpl) RunInTransaction(f func(context.Context) error, o *gae.DSTransa
txnMC.endTxn()
}()
- if err = f(context.WithValue(d.c, memContextKey, txnMC)); err != nil {
+ if err := f(context.WithValue(d.c, memContextKey, txnMC)); err != nil {
return err
}

Powered by Google App Engine
This is Rietveld 408576698