OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 package featureBreaker | |
6 | |
7 import ( | |
8 "time" | |
9 | |
10 "golang.org/x/net/context" | |
11 | |
12 "github.com/luci/gae/service/info" | |
13 ) | |
14 | |
15 type infoState struct { | |
16 *state | |
17 | |
18 info.Interface | |
19 } | |
20 | |
21 func (g *infoState) ModuleHostname(module, version, instance string) (ret string
, err error) { | |
22 err = g.run(func() (err error) { | |
23 ret, err = g.Interface.ModuleHostname(module, version, instance) | |
24 return | |
25 }) | |
26 return | |
27 } | |
28 | |
29 func (g *infoState) ServiceAccount() (ret string, err error) { | |
30 err = g.run(func() (err error) { | |
31 ret, err = g.Interface.ServiceAccount() | |
32 return | |
33 }) | |
34 return | |
35 } | |
36 | |
37 func (g *infoState) Namespace(namespace string) (ret context.Context, err error)
{ | |
38 err = g.run(func() (err error) { | |
39 ret, err = g.Interface.Namespace(namespace) | |
40 return | |
41 }) | |
42 return | |
43 } | |
44 | |
45 func (g *infoState) AccessToken(scopes ...string) (token string, expiry time.Tim
e, err error) { | |
46 err = g.run(func() (err error) { | |
47 token, expiry, err = g.Interface.AccessToken(scopes...) | |
48 return | |
49 }) | |
50 return | |
51 } | |
52 | |
53 func (g *infoState) PublicCertificates() (ret []info.Certificate, err error) { | |
54 err = g.run(func() (err error) { | |
55 ret, err = g.Interface.PublicCertificates() | |
56 return | |
57 }) | |
58 return | |
59 } | |
60 | |
61 func (g *infoState) SignBytes(bytes []byte) (keyName string, signature []byte, e
rr error) { | |
62 err = g.run(func() (err error) { | |
63 keyName, signature, err = g.Interface.SignBytes(bytes) | |
64 return | |
65 }) | |
66 return | |
67 } | |
68 | |
69 // FilterGI installs a counter info filter in the context. | |
70 func FilterGI(c context.Context, defaultError error) (context.Context, FeatureBr
eaker) { | |
71 state := newState(defaultError) | |
72 return info.AddFilters(c, func(ic context.Context, i info.Interface) inf
o.Interface { | |
73 return &infoState{state, i} | |
74 }), state | |
75 } | |
OLD | NEW |