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 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 Loading... |
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 } |
OLD | NEW |