| 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 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 type infoCounter struct { | 38 type infoCounter struct { |
| 39 c *InfoCounter | 39 c *InfoCounter |
| 40 | 40 |
| 41 gi info.Interface | 41 gi info.Interface |
| 42 } | 42 } |
| 43 | 43 |
| 44 var _ info.Interface = (*infoCounter)(nil) | 44 var _ info.Interface = (*infoCounter)(nil) |
| 45 | 45 |
| 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 { | 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 { |
| 67 » g.c.DefaultVersionHostname.up() | 67 » _ = g.c.DefaultVersionHostname.up() |
| 68 return g.gi.DefaultVersionHostname() | 68 return g.gi.DefaultVersionHostname() |
| 69 } | 69 } |
| 70 | 70 |
| 71 func (g *infoCounter) InstanceID() string { | 71 func (g *infoCounter) InstanceID() string { |
| 72 » g.c.InstanceID.up() | 72 » _ = g.c.InstanceID.up() |
| 73 return g.gi.InstanceID() | 73 return g.gi.InstanceID() |
| 74 } | 74 } |
| 75 | 75 |
| 76 func (g *infoCounter) IsDevAppServer() bool { | 76 func (g *infoCounter) IsDevAppServer() bool { |
| 77 » g.c.IsDevAppServer.up() | 77 » _ = g.c.IsDevAppServer.up() |
| 78 return g.gi.IsDevAppServer() | 78 return g.gi.IsDevAppServer() |
| 79 } | 79 } |
| 80 | 80 |
| 81 func (g *infoCounter) IsOverQuota(err error) bool { | 81 func (g *infoCounter) IsOverQuota(err error) bool { |
| 82 » g.c.IsOverQuota.up() | 82 » _ = g.c.IsOverQuota.up() |
| 83 return g.gi.IsOverQuota(err) | 83 return g.gi.IsOverQuota(err) |
| 84 } | 84 } |
| 85 | 85 |
| 86 func (g *infoCounter) IsTimeoutError(err error) bool { | 86 func (g *infoCounter) IsTimeoutError(err error) bool { |
| 87 » g.c.IsTimeoutError.up() | 87 » _ = g.c.IsTimeoutError.up() |
| 88 return g.gi.IsTimeoutError(err) | 88 return g.gi.IsTimeoutError(err) |
| 89 } | 89 } |
| 90 | 90 |
| 91 func (g *infoCounter) ModuleHostname(module, version, instance string) (string,
error) { | 91 func (g *infoCounter) ModuleHostname(module, version, instance string) (string,
error) { |
| 92 ret, err := g.gi.ModuleHostname(module, version, instance) | 92 ret, err := g.gi.ModuleHostname(module, version, instance) |
| 93 return ret, g.c.ModuleHostname.up(err) | 93 return ret, g.c.ModuleHostname.up(err) |
| 94 } | 94 } |
| 95 | 95 |
| 96 func (g *infoCounter) ModuleName() string { | 96 func (g *infoCounter) ModuleName() string { |
| 97 » g.c.ModuleName.up() | 97 » _ = g.c.ModuleName.up() |
| 98 return g.gi.ModuleName() | 98 return g.gi.ModuleName() |
| 99 } | 99 } |
| 100 | 100 |
| 101 func (g *infoCounter) RequestID() string { | 101 func (g *infoCounter) RequestID() string { |
| 102 » g.c.RequestID.up() | 102 » _ = g.c.RequestID.up() |
| 103 return g.gi.RequestID() | 103 return g.gi.RequestID() |
| 104 } | 104 } |
| 105 | 105 |
| 106 func (g *infoCounter) ServerSoftware() string { | 106 func (g *infoCounter) ServerSoftware() string { |
| 107 » g.c.ServerSoftware.up() | 107 » _ = g.c.ServerSoftware.up() |
| 108 return g.gi.ServerSoftware() | 108 return g.gi.ServerSoftware() |
| 109 } | 109 } |
| 110 | 110 |
| 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) (context.Context, error) { |
| 122 ret, err := g.gi.Namespace(namespace) | 122 ret, err := g.gi.Namespace(namespace) |
| 123 return ret, g.c.Namespace.up(err) | 123 return ret, g.c.Namespace.up(err) |
| 124 } | 124 } |
| 125 | 125 |
| 126 func (g *infoCounter) AccessToken(scopes ...string) (token string, expiry time.T
ime, err error) { | 126 func (g *infoCounter) AccessToken(scopes ...string) (string, time.Time, error) { |
| 127 » token, expiry, err = g.gi.AccessToken(scopes...) | 127 » token, expiry, err := g.gi.AccessToken(scopes...) |
| 128 » g.c.AccessToken.up(err) | 128 » return token, expiry, g.c.AccessToken.up(err) |
| 129 » return | |
| 130 } | 129 } |
| 131 | 130 |
| 132 func (g *infoCounter) PublicCertificates() ([]info.Certificate, error) { | 131 func (g *infoCounter) PublicCertificates() ([]info.Certificate, error) { |
| 133 ret, err := g.gi.PublicCertificates() | 132 ret, err := g.gi.PublicCertificates() |
| 134 return ret, g.c.PublicCertificates.up(err) | 133 return ret, g.c.PublicCertificates.up(err) |
| 135 } | 134 } |
| 136 | 135 |
| 137 func (g *infoCounter) SignBytes(bytes []byte) (keyName string, signature []byte,
err error) { | 136 func (g *infoCounter) SignBytes(bytes []byte) (string, []byte, error) { |
| 138 » keyName, signature, err = g.gi.SignBytes(bytes) | 137 » keyName, signature, err := g.gi.SignBytes(bytes) |
| 139 » g.c.SignBytes.up(err) | 138 » return keyName, signature, g.c.SignBytes.up(err) |
| 140 » return | |
| 141 } | 139 } |
| 142 | 140 |
| 143 // FilterGI installs a counter GlobalInfo filter in the context. | 141 // FilterGI installs a counter GlobalInfo filter in the context. |
| 144 func FilterGI(c context.Context) (context.Context, *InfoCounter) { | 142 func FilterGI(c context.Context) (context.Context, *InfoCounter) { |
| 145 state := &InfoCounter{} | 143 state := &InfoCounter{} |
| 146 return info.AddFilters(c, func(ic context.Context, gi info.Interface) in
fo.Interface { | 144 return info.AddFilters(c, func(ic context.Context, gi info.Interface) in
fo.Interface { |
| 147 return &infoCounter{state, gi} | 145 return &infoCounter{state, gi} |
| 148 }), state | 146 }), state |
| 149 } | 147 } |
| OLD | NEW |