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

Side by Side Diff: filter/featureBreaker/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 | « filter/count/rds.go ('k') | impl/dummy/dummy.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 featureBreaker 5 package featureBreaker
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 type dsState struct { 13 type dsState struct {
14 *state 14 *state
15 15
16 rds ds.RawInterface 16 rds ds.RawInterface
17 } 17 }
18 18
19 func (r *dsState) AllocateIDs(incomplete *ds.Key, n int) (int64, error) {
20 start := int64(0)
21 err := r.run(func() (err error) {
22 start, err = r.rds.AllocateIDs(incomplete, n)
23 return
24 })
25 return start, err
26 }
27
19 func (r *dsState) DecodeCursor(s string) (ds.Cursor, error) { 28 func (r *dsState) DecodeCursor(s string) (ds.Cursor, error) {
20 curs := ds.Cursor(nil) 29 curs := ds.Cursor(nil)
21 err := r.run(func() (err error) { 30 err := r.run(func() (err error) {
22 curs, err = r.rds.DecodeCursor(s) 31 curs, err = r.rds.DecodeCursor(s)
23 return 32 return
24 }) 33 })
25 return curs, err 34 return curs, err
26 } 35 }
27 36
28 func (r *dsState) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error { 37 func (r *dsState) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return r.rds.Testable() 71 return r.rds.Testable()
63 } 72 }
64 73
65 // FilterRDS installs a counter datastore filter in the context. 74 // FilterRDS installs a counter datastore filter in the context.
66 func FilterRDS(c context.Context, defaultError error) (context.Context, FeatureB reaker) { 75 func FilterRDS(c context.Context, defaultError error) (context.Context, FeatureB reaker) {
67 state := newState(defaultError) 76 state := newState(defaultError)
68 return ds.AddRawFilters(c, func(ic context.Context, RawDatastore ds.RawI nterface) ds.RawInterface { 77 return ds.AddRawFilters(c, func(ic context.Context, RawDatastore ds.RawI nterface) ds.RawInterface {
69 return &dsState{state, RawDatastore} 78 return &dsState{state, RawDatastore}
70 }), state 79 }), state
71 } 80 }
OLDNEW
« no previous file with comments | « filter/count/rds.go ('k') | impl/dummy/dummy.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698