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

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

Issue 1355783002: Refactor keys and queries in datastore service and implementation. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: appease errcheck Created 5 years, 3 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/mc.go ('k') | filter/dscache/context.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 "golang.org/x/net/context" 8 "golang.org/x/net/context"
9 9
10 ds "github.com/luci/gae/service/datastore" 10 ds "github.com/luci/gae/service/datastore"
11 ) 11 )
12 12
13 // DSCounter is the counter object for the datastore service. 13 // DSCounter is the counter object for the datastore service.
14 type DSCounter struct { 14 type DSCounter struct {
15 NewKey Entry
16 DecodeCursor Entry 15 DecodeCursor Entry
17 DecodeKey Entry
18 NewQuery Entry
19 RunInTransaction Entry 16 RunInTransaction Entry
20 Run Entry 17 Run Entry
21 DeleteMulti Entry 18 DeleteMulti Entry
22 GetMulti Entry 19 GetMulti Entry
23 PutMulti Entry 20 PutMulti Entry
24 } 21 }
25 22
26 type dsCounter struct { 23 type dsCounter struct {
27 c *DSCounter 24 c *DSCounter
28 25
29 ds ds.RawInterface 26 ds ds.RawInterface
30 } 27 }
31 28
32 var _ ds.RawInterface = (*dsCounter)(nil) 29 var _ ds.RawInterface = (*dsCounter)(nil)
33 30
34 func (r *dsCounter) NewKey(kind, stringID string, intID int64, parent ds.Key) ds .Key {
35 r.c.NewKey.up()
36 return r.ds.NewKey(kind, stringID, intID, parent)
37 }
38
39 func (r *dsCounter) DecodeKey(encoded string) (ds.Key, error) {
40 ret, err := r.ds.DecodeKey(encoded)
41 return ret, r.c.DecodeKey.up(err)
42 }
43
44 func (r *dsCounter) NewQuery(kind string) ds.Query {
45 r.c.NewQuery.up()
46 return r.ds.NewQuery(kind)
47 }
48
49 func (r *dsCounter) DecodeCursor(s string) (ds.Cursor, error) { 31 func (r *dsCounter) DecodeCursor(s string) (ds.Cursor, error) {
50 cursor, err := r.ds.DecodeCursor(s) 32 cursor, err := r.ds.DecodeCursor(s)
51 return cursor, r.c.DecodeCursor.up(err) 33 return cursor, r.c.DecodeCursor.up(err)
52 } 34 }
53 35
54 func (r *dsCounter) Run(q ds.Query, cb ds.RawRunCB) error { 36 func (r *dsCounter) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error {
55 return r.c.Run.up(r.ds.Run(q, cb)) 37 return r.c.Run.up(r.ds.Run(q, cb))
56 } 38 }
57 39
58 func (r *dsCounter) RunInTransaction(f func(context.Context) error, opts *ds.Tra nsactionOptions) error { 40 func (r *dsCounter) RunInTransaction(f func(context.Context) error, opts *ds.Tra nsactionOptions) error {
59 return r.c.RunInTransaction.up(r.ds.RunInTransaction(f, opts)) 41 return r.c.RunInTransaction.up(r.ds.RunInTransaction(f, opts))
60 } 42 }
61 43
62 func (r *dsCounter) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { 44 func (r *dsCounter) DeleteMulti(keys []*ds.Key, cb ds.DeleteMultiCB) error {
63 return r.c.DeleteMulti.up(r.ds.DeleteMulti(keys, cb)) 45 return r.c.DeleteMulti.up(r.ds.DeleteMulti(keys, cb))
64 } 46 }
65 47
66 func (r *dsCounter) GetMulti(keys []ds.Key, meta ds.MultiMetaGetter, cb ds.GetMu ltiCB) error { 48 func (r *dsCounter) GetMulti(keys []*ds.Key, meta ds.MultiMetaGetter, cb ds.GetM ultiCB) error {
67 return r.c.GetMulti.up(r.ds.GetMulti(keys, meta, cb)) 49 return r.c.GetMulti.up(r.ds.GetMulti(keys, meta, cb))
68 } 50 }
69 51
70 func (r *dsCounter) PutMulti(keys []ds.Key, vals []ds.PropertyMap, cb ds.PutMult iCB) error { 52 func (r *dsCounter) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMul tiCB) error {
71 return r.c.PutMulti.up(r.ds.PutMulti(keys, vals, cb)) 53 return r.c.PutMulti.up(r.ds.PutMulti(keys, vals, cb))
72 } 54 }
73 55
74 func (r *dsCounter) Testable() ds.Testable { 56 func (r *dsCounter) Testable() ds.Testable {
75 return r.ds.Testable() 57 return r.ds.Testable()
76 } 58 }
77 59
78 // FilterRDS installs a counter datastore filter in the context. 60 // FilterRDS installs a counter datastore filter in the context.
79 func FilterRDS(c context.Context) (context.Context, *DSCounter) { 61 func FilterRDS(c context.Context) (context.Context, *DSCounter) {
80 state := &DSCounter{} 62 state := &DSCounter{}
81 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface) ds.RawInterface { 63 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface) ds.RawInterface {
82 return &dsCounter{state, ds} 64 return &dsCounter{state, ds}
83 }), state 65 }), state
84 } 66 }
OLDNEW
« no previous file with comments | « filter/count/mc.go ('k') | filter/dscache/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698