| 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 12 matching lines...) Expand all Loading... |
| 23 IsDevAppServer Entry | 23 IsDevAppServer Entry |
| 24 IsOverQuota Entry | 24 IsOverQuota Entry |
| 25 IsTimeoutError Entry | 25 IsTimeoutError Entry |
| 26 ModuleHostname Entry | 26 ModuleHostname Entry |
| 27 ModuleName Entry | 27 ModuleName Entry |
| 28 RequestID Entry | 28 RequestID Entry |
| 29 ServerSoftware Entry | 29 ServerSoftware Entry |
| 30 ServiceAccount Entry | 30 ServiceAccount Entry |
| 31 VersionID Entry | 31 VersionID Entry |
| 32 Namespace Entry | 32 Namespace Entry |
| 33 MustNamespace Entry | |
| 34 AccessToken Entry | 33 AccessToken Entry |
| 35 PublicCertificates Entry | 34 PublicCertificates Entry |
| 36 SignBytes Entry | 35 SignBytes Entry |
| 37 } | 36 } |
| 38 | 37 |
| 39 type infoCounter struct { | 38 type infoCounter struct { |
| 40 c *InfoCounter | 39 c *InfoCounter |
| 41 | 40 |
| 42 » gi info.Interface | 41 » gi info.RawInterface |
| 43 } | 42 } |
| 44 | 43 |
| 45 var _ info.Interface = (*infoCounter)(nil) | 44 var _ info.RawInterface = (*infoCounter)(nil) |
| 46 | 45 |
| 47 func (g *infoCounter) AppID() string { | 46 func (g *infoCounter) AppID() string { |
| 48 _ = g.c.AppID.up() | 47 _ = g.c.AppID.up() |
| 49 return g.gi.AppID() | 48 return g.gi.AppID() |
| 50 } | 49 } |
| 51 | 50 |
| 52 func (g *infoCounter) FullyQualifiedAppID() string { | 51 func (g *infoCounter) FullyQualifiedAppID() string { |
| 53 _ = g.c.FullyQualifiedAppID.up() | 52 _ = g.c.FullyQualifiedAppID.up() |
| 54 return g.gi.FullyQualifiedAppID() | 53 return g.gi.FullyQualifiedAppID() |
| 55 } | 54 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 func (g *infoCounter) VersionID() string { | 116 func (g *infoCounter) VersionID() string { |
| 118 _ = g.c.VersionID.up() | 117 _ = g.c.VersionID.up() |
| 119 return g.gi.VersionID() | 118 return g.gi.VersionID() |
| 120 } | 119 } |
| 121 | 120 |
| 122 func (g *infoCounter) Namespace(namespace string) (context.Context, error) { | 121 func (g *infoCounter) Namespace(namespace string) (context.Context, error) { |
| 123 ret, err := g.gi.Namespace(namespace) | 122 ret, err := g.gi.Namespace(namespace) |
| 124 return ret, g.c.Namespace.up(err) | 123 return ret, g.c.Namespace.up(err) |
| 125 } | 124 } |
| 126 | 125 |
| 127 func (g *infoCounter) MustNamespace(namespace string) context.Context { | |
| 128 g.c.MustNamespace.up() | |
| 129 return g.gi.MustNamespace(namespace) | |
| 130 } | |
| 131 | |
| 132 func (g *infoCounter) AccessToken(scopes ...string) (string, time.Time, error) { | 126 func (g *infoCounter) AccessToken(scopes ...string) (string, time.Time, error) { |
| 133 token, expiry, err := g.gi.AccessToken(scopes...) | 127 token, expiry, err := g.gi.AccessToken(scopes...) |
| 134 return token, expiry, g.c.AccessToken.up(err) | 128 return token, expiry, g.c.AccessToken.up(err) |
| 135 } | 129 } |
| 136 | 130 |
| 137 func (g *infoCounter) PublicCertificates() ([]info.Certificate, error) { | 131 func (g *infoCounter) PublicCertificates() ([]info.Certificate, error) { |
| 138 ret, err := g.gi.PublicCertificates() | 132 ret, err := g.gi.PublicCertificates() |
| 139 return ret, g.c.PublicCertificates.up(err) | 133 return ret, g.c.PublicCertificates.up(err) |
| 140 } | 134 } |
| 141 | 135 |
| 142 func (g *infoCounter) SignBytes(bytes []byte) (string, []byte, error) { | 136 func (g *infoCounter) SignBytes(bytes []byte) (string, []byte, error) { |
| 143 keyName, signature, err := g.gi.SignBytes(bytes) | 137 keyName, signature, err := g.gi.SignBytes(bytes) |
| 144 return keyName, signature, g.c.SignBytes.up(err) | 138 return keyName, signature, g.c.SignBytes.up(err) |
| 145 } | 139 } |
| 146 | 140 |
| 147 func (g *infoCounter) Testable() info.Testable { | 141 func (g *infoCounter) Testable() info.Testable { |
| 148 return g.gi.Testable() | 142 return g.gi.Testable() |
| 149 } | 143 } |
| 150 | 144 |
| 151 // FilterGI installs a counter GlobalInfo filter in the context. | 145 // FilterGI installs a counter GlobalInfo filter in the context. |
| 152 func FilterGI(c context.Context) (context.Context, *InfoCounter) { | 146 func FilterGI(c context.Context) (context.Context, *InfoCounter) { |
| 153 state := &InfoCounter{} | 147 state := &InfoCounter{} |
| 154 » return info.AddFilters(c, func(ic context.Context, gi info.Interface) in
fo.Interface { | 148 » return info.AddFilters(c, func(ic context.Context, gi info.RawInterface)
info.RawInterface { |
| 155 return &infoCounter{state, gi} | 149 return &infoCounter{state, gi} |
| 156 }), state | 150 }), state |
| 157 } | 151 } |
| OLD | NEW |