OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be 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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 func (r *dsCounter) GetMulti(keys []*ds.Key, meta ds.MultiMetaGetter, cb ds.GetM
ultiCB) error { | 59 func (r *dsCounter) GetMulti(keys []*ds.Key, meta ds.MultiMetaGetter, cb ds.GetM
ultiCB) error { |
60 return r.c.GetMulti.upFilterStop(r.ds.GetMulti(keys, meta, cb)) | 60 return r.c.GetMulti.upFilterStop(r.ds.GetMulti(keys, meta, cb)) |
61 } | 61 } |
62 | 62 |
63 func (r *dsCounter) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.NewKey
CB) error { | 63 func (r *dsCounter) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.NewKey
CB) error { |
64 return r.c.PutMulti.upFilterStop(r.ds.PutMulti(keys, vals, cb)) | 64 return r.c.PutMulti.upFilterStop(r.ds.PutMulti(keys, vals, cb)) |
65 } | 65 } |
66 | 66 |
67 func (r *dsCounter) Testable() ds.Testable { | 67 func (r *dsCounter) CurrentTransaction() ds.Transaction { |
68 » return r.ds.Testable() | 68 » return r.ds.CurrentTransaction() |
| 69 } |
| 70 func (r *dsCounter) WithoutTransaction() context.Context { |
| 71 » return r.ds.WithoutTransaction() |
| 72 } |
| 73 |
| 74 func (r *dsCounter) GetTestable() ds.Testable { |
| 75 » return r.ds.GetTestable() |
69 } | 76 } |
70 | 77 |
71 // FilterRDS installs a counter datastore filter in the context. | 78 // FilterRDS installs a counter datastore filter in the context. |
72 func FilterRDS(c context.Context) (context.Context, *DSCounter) { | 79 func FilterRDS(c context.Context) (context.Context, *DSCounter) { |
73 state := &DSCounter{} | 80 state := &DSCounter{} |
74 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 { |
75 return &dsCounter{state, ds} | 82 return &dsCounter{state, ds} |
76 }), state | 83 }), state |
77 } | 84 } |
78 | 85 |
79 // upFilterStop wraps up, handling the special case datastore.Stop error. | 86 // upFilterStop wraps up, handling the special case datastore.Stop error. |
80 // datastore.Stop will pass through this function, but, unlike other error | 87 // datastore.Stop will pass through this function, but, unlike other error |
81 // codes, will be counted as a success. | 88 // codes, will be counted as a success. |
82 func (e *Entry) upFilterStop(err error) error { | 89 func (e *Entry) upFilterStop(err error) error { |
83 upErr := err | 90 upErr := err |
84 if upErr == ds.Stop { | 91 if upErr == ds.Stop { |
85 upErr = nil | 92 upErr = nil |
86 } | 93 } |
87 e.up(upErr) | 94 e.up(upErr) |
88 return err | 95 return err |
89 } | 96 } |
OLD | NEW |