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

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

Issue 1259593005: Add 'user friendly' datastore API. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: more docs Created 5 years, 4 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/featureBreaker/featurebreaker_test.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 » ds.Interface 16 » ds.RawInterface
17 } 17 }
18 18
19 func (r *dsState) DecodeKey(encoded string) (ret ds.Key, err error) { 19 func (r *dsState) DecodeKey(encoded string) (ret ds.Key, err error) {
20 err = r.run(func() (err error) { 20 err = r.run(func() (err error) {
21 » » ret, err = r.Interface.DecodeKey(encoded) 21 » » ret, err = r.RawInterface.DecodeKey(encoded)
22 return 22 return
23 }) 23 })
24 return 24 return
25 } 25 }
26 26
27 func (r *dsState) RunInTransaction(f func(c context.Context) error, opts *ds.Tra nsactionOptions) error { 27 func (r *dsState) RunInTransaction(f func(c context.Context) error, opts *ds.Tra nsactionOptions) error {
28 return r.run(func() error { 28 return r.run(func() error {
29 » » return r.Interface.RunInTransaction(f, opts) 29 » » return r.RawInterface.RunInTransaction(f, opts)
30 }) 30 })
31 } 31 }
32 32
33 // TODO(riannucci): Allow the user to specify a multierror which will propagate 33 // TODO(riannucci): Allow the user to specify a multierror which will propagate
34 // to the callback correctly. 34 // to the callback correctly.
35 35
36 func (r *dsState) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { 36 func (r *dsState) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error {
37 return r.run(func() error { 37 return r.run(func() error {
38 » » return r.Interface.DeleteMulti(keys, cb) 38 » » return r.RawInterface.DeleteMulti(keys, cb)
39 }) 39 })
40 } 40 }
41 41
42 func (r *dsState) GetMulti(keys []ds.Key, cb ds.GetMultiCB) error { 42 func (r *dsState) GetMulti(keys []ds.Key, cb ds.GetMultiCB) error {
43 return r.run(func() error { 43 return r.run(func() error {
44 » » return r.Interface.GetMulti(keys, cb) 44 » » return r.RawInterface.GetMulti(keys, cb)
45 }) 45 })
46 } 46 }
47 47
48 func (r *dsState) PutMulti(keys []ds.Key, vals []ds.PropertyLoadSaver, cb ds.Put MultiCB) error { 48 func (r *dsState) PutMulti(keys []ds.Key, vals []ds.PropertyMap, cb ds.PutMultiC B) error {
49 return r.run(func() (err error) { 49 return r.run(func() (err error) {
50 » » return r.Interface.PutMulti(keys, vals, cb) 50 » » return r.RawInterface.PutMulti(keys, vals, cb)
51 }) 51 })
52 } 52 }
53 53
54 // FilterRDS installs a counter datastore filter in the context. 54 // FilterRDS installs a counter datastore filter in the context.
55 func FilterRDS(c context.Context, defaultError error) (context.Context, FeatureB reaker) { 55 func FilterRDS(c context.Context, defaultError error) (context.Context, FeatureB reaker) {
56 state := newState(defaultError) 56 state := newState(defaultError)
57 » return ds.AddFilters(c, func(ic context.Context, datastore ds.Interface) ds.Interface { 57 » return ds.AddRawFilters(c, func(ic context.Context, RawDatastore ds.RawI nterface) ds.RawInterface {
58 » » return &dsState{state, datastore} 58 » » return &dsState{state, RawDatastore}
59 }), state 59 }), state
60 } 60 }
OLDNEW
« no previous file with comments | « filter/featureBreaker/featurebreaker_test.go ('k') | impl/dummy/dummy.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698