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 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 mc "github.com/luci/gae/service/memcache" | 10 mc "github.com/luci/gae/service/memcache" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 func (m *mcState) DeleteMulti(keys []string, cb mc.RawCB) error { | 31 func (m *mcState) DeleteMulti(keys []string, cb mc.RawCB) error { |
32 return m.run(func() error { return m.RawInterface.DeleteMulti(keys, cb) }) | 32 return m.run(func() error { return m.RawInterface.DeleteMulti(keys, cb) }) |
33 } | 33 } |
34 | 34 |
35 func (m *mcState) CompareAndSwapMulti(items []mc.Item, cb mc.RawCB) error { | 35 func (m *mcState) CompareAndSwapMulti(items []mc.Item, cb mc.RawCB) error { |
36 return m.run(func() error { return m.RawInterface.CompareAndSwapMulti(it ems, cb) }) | 36 return m.run(func() error { return m.RawInterface.CompareAndSwapMulti(it ems, cb) }) |
37 } | 37 } |
38 | 38 |
39 func (m *mcState) Flush() error { | 39 func (m *mcState) Flush() error { |
40 » return m.run(m.RawInterface.Flush) | 40 » return m.run(func() error { |
41 » » return m.RawInterface.Flush() | |
42 » }) | |
iannucci
2016/09/16 01:01:13
hm... why was this transformation necessary?
dnj
2016/09/16 05:44:42
Don't remember, un-did it.
| |
41 } | 43 } |
42 | 44 |
43 func (m *mcState) Stats() (ret *mc.Statistics, err error) { | 45 func (m *mcState) Stats() (ret *mc.Statistics, err error) { |
44 err = m.run(func() (err error) { | 46 err = m.run(func() (err error) { |
45 ret, err = m.RawInterface.Stats() | 47 ret, err = m.RawInterface.Stats() |
46 return | 48 return |
47 }) | 49 }) |
48 return | 50 return |
49 } | 51 } |
50 | 52 |
51 // FilterMC installs a featureBreaker mc filter in the context. | 53 // FilterMC installs a featureBreaker mc filter in the context. |
52 func FilterMC(c context.Context, defaultError error) (context.Context, FeatureBr eaker) { | 54 func FilterMC(c context.Context, defaultError error) (context.Context, FeatureBr eaker) { |
53 state := newState(defaultError) | 55 state := newState(defaultError) |
54 return mc.AddRawFilters(c, func(ic context.Context, rds mc.RawInterface) mc.RawInterface { | 56 return mc.AddRawFilters(c, func(ic context.Context, rds mc.RawInterface) mc.RawInterface { |
55 return &mcState{state, rds} | 57 return &mcState{state, rds} |
56 }), state | 58 }), state |
57 } | 59 } |
OLD | NEW |