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 dscache | 5 package dscache |
6 | 6 |
7 import ( | 7 import ( |
8 "time" | 8 "time" |
9 | 9 |
10 ds "github.com/luci/gae/service/datastore" | 10 ds "github.com/luci/gae/service/datastore" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 if err := d.mc.CompareAndSwapMulti(toCas); err != nil { | 112 if err := d.mc.CompareAndSwapMulti(toCas); err != nil { |
113 (log.Fields{log.ErrorKey: err}).Warningf( | 113 (log.Fields{log.ErrorKey: err}).Warningf( |
114 d.c, "dscache: GetMulti: memcache.Compar
eAndSwapMulti") | 114 d.c, "dscache: GetMulti: memcache.Compar
eAndSwapMulti") |
115 } | 115 } |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 // finally, run the callback for all of the decoded items and the errors
, | 119 // finally, run the callback for all of the decoded items and the errors
, |
120 // if any. | 120 // if any. |
121 for i, dec := range p.decoded { | 121 for i, dec := range p.decoded { |
122 » » cb(dec, p.lme.GetOne(i)) | 122 » » if err := cb(dec, p.lme.GetOne(i)); err != nil { |
| 123 » » » return err |
| 124 » » } |
123 } | 125 } |
124 | 126 |
125 return nil | 127 return nil |
126 } | 128 } |
127 | 129 |
128 func (d *dsCache) RunInTransaction(f func(context.Context) error, opts *ds.Trans
actionOptions) error { | 130 func (d *dsCache) RunInTransaction(f func(context.Context) error, opts *ds.Trans
actionOptions) error { |
129 txnState := dsTxnState{} | 131 txnState := dsTxnState{} |
130 err := d.RawInterface.RunInTransaction(func(ctx context.Context) error { | 132 err := d.RawInterface.RunInTransaction(func(ctx context.Context) error { |
131 txnState.reset() | 133 txnState.reset() |
132 err := f(context.WithValue(ctx, dsTxnCacheKey, &txnState)) | 134 err := f(context.WithValue(ctx, dsTxnCacheKey, &txnState)) |
133 if err == nil { | 135 if err == nil { |
134 err = txnState.apply(d.supportContext) | 136 err = txnState.apply(d.supportContext) |
135 } | 137 } |
136 return err | 138 return err |
137 }, opts) | 139 }, opts) |
138 if err == nil { | 140 if err == nil { |
139 txnState.release(d.supportContext) | 141 txnState.release(d.supportContext) |
140 } | 142 } |
141 return err | 143 return err |
142 } | 144 } |
OLD | NEW |