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

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

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint 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 unified diff | Download patch
« no previous file with comments | « filters/count/mc.go ('k') | filters/count/tq.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 » "github.com/luci/gae" 10 » rds "github.com/luci/gae/service/rawdatastore"
11 ) 11 )
12 12
13 // RDSCounter is the counter object for the RawDatastore service. 13 // RDSCounter is the counter object for the RawDatastore service.
14 type RDSCounter struct { 14 type RDSCounter struct {
15 NewKey Entry 15 NewKey Entry
16 DecodeKey Entry 16 DecodeKey Entry
17 NewQuery Entry 17 NewQuery Entry
18 Count Entry 18 Count Entry
19 RunInTransaction Entry 19 RunInTransaction Entry
20 Run Entry 20 Run Entry
21 GetAll Entry 21 GetAll Entry
22 Put Entry 22 Put Entry
23 Get Entry 23 Get Entry
24 Delete Entry 24 Delete Entry
25 DeleteMulti Entry 25 DeleteMulti Entry
26 GetMulti Entry 26 GetMulti Entry
27 PutMulti Entry 27 PutMulti Entry
28 } 28 }
29 29
30 type rdsCounter struct { 30 type rdsCounter struct {
31 c *RDSCounter 31 c *RDSCounter
32 32
33 » rds gae.RawDatastore 33 » rds rds.Interface
34 } 34 }
35 35
36 var _ gae.RawDatastore = (*rdsCounter)(nil) 36 var _ rds.Interface = (*rdsCounter)(nil)
37 37
38 func (r *rdsCounter) NewKey(kind, stringID string, intID int64, parent gae.DSKey ) gae.DSKey { 38 func (r *rdsCounter) NewKey(kind, stringID string, intID int64, parent rds.Key) rds.Key {
39 r.c.NewKey.up() 39 r.c.NewKey.up()
40 return r.rds.NewKey(kind, stringID, intID, parent) 40 return r.rds.NewKey(kind, stringID, intID, parent)
41 } 41 }
42 42
43 func (r *rdsCounter) DecodeKey(encoded string) (gae.DSKey, error) { 43 func (r *rdsCounter) DecodeKey(encoded string) (rds.Key, error) {
44 ret, err := r.rds.DecodeKey(encoded) 44 ret, err := r.rds.DecodeKey(encoded)
45 return ret, r.c.DecodeKey.up(err) 45 return ret, r.c.DecodeKey.up(err)
46 } 46 }
47 47
48 func (r *rdsCounter) NewQuery(kind string) gae.DSQuery { 48 func (r *rdsCounter) NewQuery(kind string) rds.Query {
49 r.c.NewQuery.up() 49 r.c.NewQuery.up()
50 return r.rds.NewQuery(kind) 50 return r.rds.NewQuery(kind)
51 } 51 }
52 52
53 func (r *rdsCounter) Run(q gae.DSQuery) gae.RDSIterator { 53 func (r *rdsCounter) Run(q rds.Query) rds.Iterator {
54 r.c.Run.up() 54 r.c.Run.up()
55 return r.rds.Run(q) 55 return r.rds.Run(q)
56 } 56 }
57 57
58 func (r *rdsCounter) GetAll(q gae.DSQuery, dst *[]gae.DSPropertyMap) ([]gae.DSKe y, error) { 58 func (r *rdsCounter) GetAll(q rds.Query, dst *[]rds.PropertyMap) ([]rds.Key, err or) {
59 ret, err := r.rds.GetAll(q, dst) 59 ret, err := r.rds.GetAll(q, dst)
60 return ret, r.c.GetAll.up(err) 60 return ret, r.c.GetAll.up(err)
61 } 61 }
62 62
63 func (r *rdsCounter) Count(q gae.DSQuery) (int, error) { 63 func (r *rdsCounter) Count(q rds.Query) (int, error) {
64 ret, err := r.rds.Count(q) 64 ret, err := r.rds.Count(q)
65 return ret, r.c.Count.up(err) 65 return ret, r.c.Count.up(err)
66 } 66 }
67 67
68 func (r *rdsCounter) RunInTransaction(f func(context.Context) error, opts *gae.D STransactionOptions) error { 68 func (r *rdsCounter) RunInTransaction(f func(context.Context) error, opts *rds.T ransactionOptions) error {
69 return r.c.RunInTransaction.up(r.rds.RunInTransaction(f, opts)) 69 return r.c.RunInTransaction.up(r.rds.RunInTransaction(f, opts))
70 } 70 }
71 71
72 func (r *rdsCounter) Put(key gae.DSKey, src gae.DSPropertyLoadSaver) (gae.DSKey, error) { 72 func (r *rdsCounter) Put(key rds.Key, src rds.PropertyLoadSaver) (rds.Key, error ) {
73 ret, err := r.rds.Put(key, src) 73 ret, err := r.rds.Put(key, src)
74 return ret, r.c.Put.up(err) 74 return ret, r.c.Put.up(err)
75 } 75 }
76 76
77 func (r *rdsCounter) Get(key gae.DSKey, dst gae.DSPropertyLoadSaver) error { 77 func (r *rdsCounter) Get(key rds.Key, dst rds.PropertyLoadSaver) error {
78 return r.c.Get.up(r.rds.Get(key, dst)) 78 return r.c.Get.up(r.rds.Get(key, dst))
79 } 79 }
80 80
81 func (r *rdsCounter) Delete(key gae.DSKey) error { 81 func (r *rdsCounter) Delete(key rds.Key) error {
82 return r.c.Delete.up(r.rds.Delete(key)) 82 return r.c.Delete.up(r.rds.Delete(key))
83 } 83 }
84 84
85 func (r *rdsCounter) DeleteMulti(keys []gae.DSKey) error { 85 func (r *rdsCounter) DeleteMulti(keys []rds.Key) error {
86 return r.c.DeleteMulti.up(r.rds.DeleteMulti(keys)) 86 return r.c.DeleteMulti.up(r.rds.DeleteMulti(keys))
87 } 87 }
88 88
89 func (r *rdsCounter) GetMulti(keys []gae.DSKey, dst []gae.DSPropertyLoadSaver) e rror { 89 func (r *rdsCounter) GetMulti(keys []rds.Key, dst []rds.PropertyLoadSaver) error {
90 return r.c.GetMulti.up(r.rds.GetMulti(keys, dst)) 90 return r.c.GetMulti.up(r.rds.GetMulti(keys, dst))
91 } 91 }
92 92
93 func (r *rdsCounter) PutMulti(keys []gae.DSKey, src []gae.DSPropertyLoadSaver) ( []gae.DSKey, error) { 93 func (r *rdsCounter) PutMulti(keys []rds.Key, src []rds.PropertyLoadSaver) ([]rd s.Key, error) {
94 ret, err := r.rds.PutMulti(keys, src) 94 ret, err := r.rds.PutMulti(keys, src)
95 return ret, r.c.PutMulti.up(err) 95 return ret, r.c.PutMulti.up(err)
96 } 96 }
97 97
98 // FilterRDS installs a counter RawDatastore filter in the context. 98 // FilterRDS installs a counter RawDatastore filter in the context.
99 func FilterRDS(c context.Context) (context.Context, *RDSCounter) { 99 func FilterRDS(c context.Context) (context.Context, *RDSCounter) {
100 state := &RDSCounter{} 100 state := &RDSCounter{}
101 » return gae.AddRDSFilters(c, func(ic context.Context, rds gae.RawDatastor e) gae.RawDatastore { 101 » return rds.AddFilters(c, func(ic context.Context, rds rds.Interface) rds .Interface {
102 return &rdsCounter{state, rds} 102 return &rdsCounter{state, rds}
103 }), state 103 }), state
104 } 104 }
OLDNEW
« no previous file with comments | « filters/count/mc.go ('k') | filters/count/tq.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698