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

Side by Side Diff: filter/count/rds.go

Issue 1844183003: Don't filter "Stop" error in raw interface. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Count filter doesn't count Stop as error. Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « filter/count/count_test.go ('k') | impl/memory/datastore_data.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package count 5 package count
6 6
7 import ( 7 import (
8 "github.com/luci/luci-go/common/errors"
8 "golang.org/x/net/context" 9 "golang.org/x/net/context"
9 10
10 ds "github.com/luci/gae/service/datastore" 11 ds "github.com/luci/gae/service/datastore"
11 ) 12 )
12 13
13 // DSCounter is the counter object for the datastore service. 14 // DSCounter is the counter object for the datastore service.
14 type DSCounter struct { 15 type DSCounter struct {
15 AllocateIDs Entry 16 AllocateIDs Entry
16 DecodeCursor Entry 17 DecodeCursor Entry
17 RunInTransaction Entry 18 RunInTransaction Entry
(...skipping 16 matching lines...) Expand all
34 start, err := r.ds.AllocateIDs(incomplete, n) 35 start, err := r.ds.AllocateIDs(incomplete, n)
35 return start, r.c.AllocateIDs.up(err) 36 return start, r.c.AllocateIDs.up(err)
36 } 37 }
37 38
38 func (r *dsCounter) DecodeCursor(s string) (ds.Cursor, error) { 39 func (r *dsCounter) DecodeCursor(s string) (ds.Cursor, error) {
39 cursor, err := r.ds.DecodeCursor(s) 40 cursor, err := r.ds.DecodeCursor(s)
40 return cursor, r.c.DecodeCursor.up(err) 41 return cursor, r.c.DecodeCursor.up(err)
41 } 42 }
42 43
43 func (r *dsCounter) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error { 44 func (r *dsCounter) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error {
44 » return r.c.Run.up(r.ds.Run(q, cb)) 45 » return r.c.Run.up(errors.Filter(r.ds.Run(q, cb), ds.Stop))
45 } 46 }
46 47
47 func (r *dsCounter) Count(q *ds.FinalizedQuery) (int64, error) { 48 func (r *dsCounter) Count(q *ds.FinalizedQuery) (int64, error) {
48 count, err := r.ds.Count(q) 49 count, err := r.ds.Count(q)
49 return count, r.c.Count.up(err) 50 return count, r.c.Count.up(err)
50 } 51 }
51 52
52 func (r *dsCounter) RunInTransaction(f func(context.Context) error, opts *ds.Tra nsactionOptions) error { 53 func (r *dsCounter) RunInTransaction(f func(context.Context) error, opts *ds.Tra nsactionOptions) error {
53 return r.c.RunInTransaction.up(r.ds.RunInTransaction(f, opts)) 54 return r.c.RunInTransaction.up(r.ds.RunInTransaction(f, opts))
54 } 55 }
55 56
56 func (r *dsCounter) DeleteMulti(keys []*ds.Key, cb ds.DeleteMultiCB) error { 57 func (r *dsCounter) DeleteMulti(keys []*ds.Key, cb ds.DeleteMultiCB) error {
57 » return r.c.DeleteMulti.up(r.ds.DeleteMulti(keys, cb)) 58 » return r.c.DeleteMulti.up(errors.Filter(r.ds.DeleteMulti(keys, cb), ds.S top))
58 } 59 }
59 60
60 func (r *dsCounter) GetMulti(keys []*ds.Key, meta ds.MultiMetaGetter, cb ds.GetM ultiCB) error { 61 func (r *dsCounter) GetMulti(keys []*ds.Key, meta ds.MultiMetaGetter, cb ds.GetM ultiCB) error {
61 » return r.c.GetMulti.up(r.ds.GetMulti(keys, meta, cb)) 62 » return r.c.GetMulti.up(errors.Filter(r.ds.GetMulti(keys, meta, cb), ds.S top))
62 } 63 }
63 64
64 func (r *dsCounter) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMul tiCB) error { 65 func (r *dsCounter) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMul tiCB) error {
65 » return r.c.PutMulti.up(r.ds.PutMulti(keys, vals, cb)) 66 » return r.c.PutMulti.up(errors.Filter(r.ds.PutMulti(keys, vals, cb), ds.S top))
66 } 67 }
67 68
68 func (r *dsCounter) Testable() ds.Testable { 69 func (r *dsCounter) Testable() ds.Testable {
69 return r.ds.Testable() 70 return r.ds.Testable()
70 } 71 }
71 72
72 // FilterRDS installs a counter datastore filter in the context. 73 // FilterRDS installs a counter datastore filter in the context.
73 func FilterRDS(c context.Context) (context.Context, *DSCounter) { 74 func FilterRDS(c context.Context) (context.Context, *DSCounter) {
74 state := &DSCounter{} 75 state := &DSCounter{}
75 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface) ds.RawInterface { 76 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface) ds.RawInterface {
76 return &dsCounter{state, ds} 77 return &dsCounter{state, ds}
77 }), state 78 }), state
78 } 79 }
OLDNEW
« no previous file with comments | « filter/count/count_test.go ('k') | impl/memory/datastore_data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698