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

Unified Diff: impl/memory/datastore_data.go

Issue 1521823003: Clean up callback interfaces. (Closed) Base URL: https://github.com/luci/gae.git@extra
Patch Set: fixins Created 5 years 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
« no previous file with comments | « filter/txnBuf/txnbuf_test.go ('k') | impl/memory/datastore_query_execution.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_data.go
diff --git a/impl/memory/datastore_data.go b/impl/memory/datastore_data.go
index dbb49783b1083ef574d3ff0139ceab64dc373d10..15ffc2f797c5cd5b6a45150c2177f9189e5e26d0 100644
--- a/impl/memory/datastore_data.go
+++ b/impl/memory/datastore_data.go
@@ -249,7 +249,7 @@ func (d *dataStoreData) fixKeyLocked(ents *memCollection, key *ds.Key) (*ds.Key,
return key, nil
}
-func (d *dataStoreData) putMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMultiCB) {
+func (d *dataStoreData) putMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMultiCB) error {
ns := keys[0].Namespace()
for i, k := range keys {
@@ -282,9 +282,15 @@ func (d *dataStoreData) putMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.Pu
return
}()
if cb != nil {
- cb(k, err)
+ if err := cb(k, err); err != nil {
+ if err == ds.Stop {
+ return nil
+ }
+ return err
+ }
}
}
+ return nil
}
func getMultiInner(keys []*ds.Key, cb ds.GetMultiCB, getColl func() (*memCollection, error)) error {
@@ -318,7 +324,7 @@ func (d *dataStoreData) getMulti(keys []*ds.Key, cb ds.GetMultiCB) error {
})
}
-func (d *dataStoreData) delMulti(keys []*ds.Key, cb ds.DeleteMultiCB) {
+func (d *dataStoreData) delMulti(keys []*ds.Key, cb ds.DeleteMultiCB) error {
ns := keys[0].Namespace()
hasEntsInNS := func() bool {
@@ -351,14 +357,25 @@ func (d *dataStoreData) delMulti(keys []*ds.Key, cb ds.DeleteMultiCB) {
return nil
}()
if cb != nil {
- cb(err)
+ if err := cb(err); err != nil {
+ if err == ds.Stop {
+ return nil
+ }
+ return err
+ }
}
}
} else if cb != nil {
for range keys {
- cb(nil)
+ if err := cb(nil); err != nil {
+ if err == ds.Stop {
+ return nil
+ }
+ return err
+ }
}
}
+ return nil
}
func (d *dataStoreData) canApplyTxn(obj memContextObj) bool {
@@ -395,16 +412,14 @@ func (d *dataStoreData) applyTxn(c context.Context, obj memContextObj) {
}
// TODO(riannucci): refactor to do just 1 putMulti, and 1 delMulti
for _, m := range muts {
- err := error(nil)
k := m.key
if m.data == nil {
- d.delMulti([]*ds.Key{k},
- func(e error) { err = e })
+ impossible(d.delMulti([]*ds.Key{k},
+ func(e error) error { return e }))
} else {
- d.putMulti([]*ds.Key{m.key}, []ds.PropertyMap{m.data},
- func(_ *ds.Key, e error) { err = e })
+ impossible(d.putMulti([]*ds.Key{m.key}, []ds.PropertyMap{m.data},
+ func(_ *ds.Key, e error) error { return e }))
}
- impossible(err)
}
}
}
« no previous file with comments | « filter/txnBuf/txnbuf_test.go ('k') | impl/memory/datastore_query_execution.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698