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

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

Issue 1357343002: Add missing AllocateIDs API. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: add panic 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 | « no previous file | filter/featureBreaker/rds.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 AllocateIDs Entry
15 DecodeCursor Entry 16 DecodeCursor Entry
16 RunInTransaction Entry 17 RunInTransaction Entry
17 Run Entry 18 Run Entry
18 DeleteMulti Entry 19 DeleteMulti Entry
19 GetMulti Entry 20 GetMulti Entry
20 PutMulti Entry 21 PutMulti Entry
21 } 22 }
22 23
23 type dsCounter struct { 24 type dsCounter struct {
24 c *DSCounter 25 c *DSCounter
25 26
26 ds ds.RawInterface 27 ds ds.RawInterface
27 } 28 }
28 29
29 var _ ds.RawInterface = (*dsCounter)(nil) 30 var _ ds.RawInterface = (*dsCounter)(nil)
30 31
32 func (r *dsCounter) AllocateIDs(incomplete *ds.Key, n int) (int64, error) {
33 start, err := r.ds.AllocateIDs(incomplete, n)
34 return start, r.c.AllocateIDs.up(err)
35 }
36
31 func (r *dsCounter) DecodeCursor(s string) (ds.Cursor, error) { 37 func (r *dsCounter) DecodeCursor(s string) (ds.Cursor, error) {
32 cursor, err := r.ds.DecodeCursor(s) 38 cursor, err := r.ds.DecodeCursor(s)
33 return cursor, r.c.DecodeCursor.up(err) 39 return cursor, r.c.DecodeCursor.up(err)
34 } 40 }
35 41
36 func (r *dsCounter) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error { 42 func (r *dsCounter) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error {
37 return r.c.Run.up(r.ds.Run(q, cb)) 43 return r.c.Run.up(r.ds.Run(q, cb))
38 } 44 }
39 45
40 func (r *dsCounter) RunInTransaction(f func(context.Context) error, opts *ds.Tra nsactionOptions) error { 46 func (r *dsCounter) RunInTransaction(f func(context.Context) error, opts *ds.Tra nsactionOptions) error {
(...skipping 16 matching lines...) Expand all
57 return r.ds.Testable() 63 return r.ds.Testable()
58 } 64 }
59 65
60 // FilterRDS installs a counter datastore filter in the context. 66 // FilterRDS installs a counter datastore filter in the context.
61 func FilterRDS(c context.Context) (context.Context, *DSCounter) { 67 func FilterRDS(c context.Context) (context.Context, *DSCounter) {
62 state := &DSCounter{} 68 state := &DSCounter{}
63 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface) ds.RawInterface { 69 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface) ds.RawInterface {
64 return &dsCounter{state, ds} 70 return &dsCounter{state, ds}
65 }), state 71 }), state
66 } 72 }
OLDNEW
« no previous file with comments | « no previous file | filter/featureBreaker/rds.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698