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

Unified Diff: filter/count/rds.go

Issue 1846123002: Fix missing/broken ds.Stop handling in raw DS. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Better "count" helper function. Created 4 years, 9 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
« no previous file with comments | « no previous file | filter/dsQueryBatch/filter.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/count/rds.go
diff --git a/filter/count/rds.go b/filter/count/rds.go
index eeeccc520163d5eada3f771154617164c3df35da..69e903aea911634fca022ddd4881380048793255 100644
--- a/filter/count/rds.go
+++ b/filter/count/rds.go
@@ -5,7 +5,6 @@
package count
import (
- "github.com/luci/luci-go/common/errors"
"golang.org/x/net/context"
ds "github.com/luci/gae/service/datastore"
@@ -42,7 +41,7 @@ func (r *dsCounter) DecodeCursor(s string) (ds.Cursor, error) {
}
func (r *dsCounter) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error {
- return r.c.Run.up(errors.Filter(r.ds.Run(q, cb), ds.Stop))
+ return r.c.Run.upFilterStop(r.ds.Run(q, cb))
}
func (r *dsCounter) Count(q *ds.FinalizedQuery) (int64, error) {
@@ -55,15 +54,15 @@ func (r *dsCounter) RunInTransaction(f func(context.Context) error, opts *ds.Tra
}
func (r *dsCounter) DeleteMulti(keys []*ds.Key, cb ds.DeleteMultiCB) error {
- return r.c.DeleteMulti.up(errors.Filter(r.ds.DeleteMulti(keys, cb), ds.Stop))
+ return r.c.DeleteMulti.upFilterStop(r.ds.DeleteMulti(keys, cb))
}
func (r *dsCounter) GetMulti(keys []*ds.Key, meta ds.MultiMetaGetter, cb ds.GetMultiCB) error {
- return r.c.GetMulti.up(errors.Filter(r.ds.GetMulti(keys, meta, cb), ds.Stop))
+ return r.c.GetMulti.upFilterStop(r.ds.GetMulti(keys, meta, cb))
}
func (r *dsCounter) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMultiCB) error {
- return r.c.PutMulti.up(errors.Filter(r.ds.PutMulti(keys, vals, cb), ds.Stop))
+ return r.c.PutMulti.upFilterStop(r.ds.PutMulti(keys, vals, cb))
}
func (r *dsCounter) Testable() ds.Testable {
@@ -77,3 +76,15 @@ func FilterRDS(c context.Context) (context.Context, *DSCounter) {
return &dsCounter{state, ds}
}), state
}
+
+// upFilterStop wraps up, handling the special case datastore.Stop error.
+// datastore.Stop will pass through this function, but, unlike other error
+// codes, will be counted as a success.
+func (e *Entry) upFilterStop(err error) error {
+ upErr := err
+ if upErr == ds.Stop {
+ upErr = nil
+ }
+ e.up(upErr)
+ return err
+}
« no previous file with comments | « no previous file | filter/dsQueryBatch/filter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698