OLD | NEW |
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 | 15 NewKey Entry |
| 16 DecodeCursor Entry |
16 DecodeKey Entry | 17 DecodeKey Entry |
17 NewQuery Entry | 18 NewQuery Entry |
18 RunInTransaction Entry | 19 RunInTransaction Entry |
19 Run Entry | 20 Run Entry |
20 DeleteMulti Entry | 21 DeleteMulti Entry |
21 GetMulti Entry | 22 GetMulti Entry |
22 PutMulti Entry | 23 PutMulti Entry |
23 } | 24 } |
24 | 25 |
25 type dsCounter struct { | 26 type dsCounter struct { |
(...skipping 12 matching lines...) Expand all Loading... |
38 func (r *dsCounter) DecodeKey(encoded string) (ds.Key, error) { | 39 func (r *dsCounter) DecodeKey(encoded string) (ds.Key, error) { |
39 ret, err := r.ds.DecodeKey(encoded) | 40 ret, err := r.ds.DecodeKey(encoded) |
40 return ret, r.c.DecodeKey.up(err) | 41 return ret, r.c.DecodeKey.up(err) |
41 } | 42 } |
42 | 43 |
43 func (r *dsCounter) NewQuery(kind string) ds.Query { | 44 func (r *dsCounter) NewQuery(kind string) ds.Query { |
44 r.c.NewQuery.up() | 45 r.c.NewQuery.up() |
45 return r.ds.NewQuery(kind) | 46 return r.ds.NewQuery(kind) |
46 } | 47 } |
47 | 48 |
| 49 func (r *dsCounter) DecodeCursor(s string) (ds.Cursor, error) { |
| 50 cursor, err := r.ds.DecodeCursor(s) |
| 51 return cursor, r.c.DecodeCursor.up(err) |
| 52 } |
| 53 |
48 func (r *dsCounter) Run(q ds.Query, cb ds.RawRunCB) error { | 54 func (r *dsCounter) Run(q ds.Query, cb ds.RawRunCB) error { |
49 return r.c.Run.up(r.ds.Run(q, cb)) | 55 return r.c.Run.up(r.ds.Run(q, cb)) |
50 } | 56 } |
51 | 57 |
52 func (r *dsCounter) RunInTransaction(f func(context.Context) error, opts *ds.Tra
nsactionOptions) error { | 58 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)) | 59 return r.c.RunInTransaction.up(r.ds.RunInTransaction(f, opts)) |
54 } | 60 } |
55 | 61 |
56 func (r *dsCounter) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { | 62 func (r *dsCounter) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { |
57 return r.c.DeleteMulti.up(r.ds.DeleteMulti(keys, cb)) | 63 return r.c.DeleteMulti.up(r.ds.DeleteMulti(keys, cb)) |
(...skipping 11 matching lines...) Expand all Loading... |
69 return r.ds.Testable() | 75 return r.ds.Testable() |
70 } | 76 } |
71 | 77 |
72 // FilterRDS installs a counter datastore filter in the context. | 78 // FilterRDS installs a counter datastore filter in the context. |
73 func FilterRDS(c context.Context) (context.Context, *DSCounter) { | 79 func FilterRDS(c context.Context) (context.Context, *DSCounter) { |
74 state := &DSCounter{} | 80 state := &DSCounter{} |
75 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface)
ds.RawInterface { | 81 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface)
ds.RawInterface { |
76 return &dsCounter{state, ds} | 82 return &dsCounter{state, ds} |
77 }), state | 83 }), state |
78 } | 84 } |
OLD | NEW |