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 "time" | 8 "time" |
9 | 9 |
10 "golang.org/x/net/context" | 10 "golang.org/x/net/context" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 func (g *infoCounter) AppID() string { | 46 func (g *infoCounter) AppID() string { |
47 _ = g.c.AppID.up() | 47 _ = g.c.AppID.up() |
48 return g.gi.AppID() | 48 return g.gi.AppID() |
49 } | 49 } |
50 | 50 |
51 func (g *infoCounter) FullyQualifiedAppID() string { | 51 func (g *infoCounter) FullyQualifiedAppID() string { |
52 _ = g.c.FullyQualifiedAppID.up() | 52 _ = g.c.FullyQualifiedAppID.up() |
53 return g.gi.FullyQualifiedAppID() | 53 return g.gi.FullyQualifiedAppID() |
54 } | 54 } |
55 | 55 |
56 func (g *infoCounter) GetNamespace() (string, bool) { | 56 func (g *infoCounter) GetNamespace() string { |
57 _ = g.c.GetNamespace.up() | 57 _ = g.c.GetNamespace.up() |
58 return g.gi.GetNamespace() | 58 return g.gi.GetNamespace() |
59 } | 59 } |
60 | 60 |
61 func (g *infoCounter) Datacenter() string { | 61 func (g *infoCounter) Datacenter() string { |
62 _ = g.c.Datacenter.up() | 62 _ = g.c.Datacenter.up() |
63 return g.gi.Datacenter() | 63 return g.gi.Datacenter() |
64 } | 64 } |
65 | 65 |
66 func (g *infoCounter) DefaultVersionHostname() string { | 66 func (g *infoCounter) DefaultVersionHostname() string { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 func (g *infoCounter) ServiceAccount() (string, error) { | 111 func (g *infoCounter) ServiceAccount() (string, error) { |
112 ret, err := g.gi.ServiceAccount() | 112 ret, err := g.gi.ServiceAccount() |
113 return ret, g.c.ServiceAccount.up(err) | 113 return ret, g.c.ServiceAccount.up(err) |
114 } | 114 } |
115 | 115 |
116 func (g *infoCounter) VersionID() string { | 116 func (g *infoCounter) VersionID() string { |
117 _ = g.c.VersionID.up() | 117 _ = g.c.VersionID.up() |
118 return g.gi.VersionID() | 118 return g.gi.VersionID() |
119 } | 119 } |
120 | 120 |
121 func (g *infoCounter) Namespace(namespace string) (context.Context, error) { | 121 func (g *infoCounter) Namespace(namespace string) (c context.Context, err error)
{ |
122 » ret, err := g.gi.Namespace(namespace) | 122 » c, err = g.gi.Namespace(namespace) |
123 » return ret, g.c.Namespace.up(err) | 123 » g.c.Namespace.up(err) |
| 124 » return |
124 } | 125 } |
125 | 126 |
126 func (g *infoCounter) AccessToken(scopes ...string) (string, time.Time, error) { | 127 func (g *infoCounter) AccessToken(scopes ...string) (string, time.Time, error) { |
127 token, expiry, err := g.gi.AccessToken(scopes...) | 128 token, expiry, err := g.gi.AccessToken(scopes...) |
128 return token, expiry, g.c.AccessToken.up(err) | 129 return token, expiry, g.c.AccessToken.up(err) |
129 } | 130 } |
130 | 131 |
131 func (g *infoCounter) PublicCertificates() ([]info.Certificate, error) { | 132 func (g *infoCounter) PublicCertificates() ([]info.Certificate, error) { |
132 ret, err := g.gi.PublicCertificates() | 133 ret, err := g.gi.PublicCertificates() |
133 return ret, g.c.PublicCertificates.up(err) | 134 return ret, g.c.PublicCertificates.up(err) |
134 } | 135 } |
135 | 136 |
136 func (g *infoCounter) SignBytes(bytes []byte) (string, []byte, error) { | 137 func (g *infoCounter) SignBytes(bytes []byte) (string, []byte, error) { |
137 keyName, signature, err := g.gi.SignBytes(bytes) | 138 keyName, signature, err := g.gi.SignBytes(bytes) |
138 return keyName, signature, g.c.SignBytes.up(err) | 139 return keyName, signature, g.c.SignBytes.up(err) |
139 } | 140 } |
140 | 141 |
141 func (g *infoCounter) Testable() info.Testable { | 142 func (g *infoCounter) GetTestable() info.Testable { |
142 » return g.gi.Testable() | 143 » return g.gi.GetTestable() |
143 } | 144 } |
144 | 145 |
145 // FilterGI installs a counter GlobalInfo filter in the context. | 146 // FilterGI installs a counter GlobalInfo filter in the context. |
146 func FilterGI(c context.Context) (context.Context, *InfoCounter) { | 147 func FilterGI(c context.Context) (context.Context, *InfoCounter) { |
147 state := &InfoCounter{} | 148 state := &InfoCounter{} |
148 return info.AddFilters(c, func(ic context.Context, gi info.RawInterface)
info.RawInterface { | 149 return info.AddFilters(c, func(ic context.Context, gi info.RawInterface)
info.RawInterface { |
149 return &infoCounter{state, gi} | 150 return &infoCounter{state, gi} |
150 }), state | 151 }), state |
151 } | 152 } |
OLD | NEW |