aboutsummaryrefslogtreecommitdiff
path: root/vendor/google.golang.org
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2017-02-12 22:24:33 +0000
committerNiall Sheridan <nsheridan@gmail.com>2017-02-12 22:24:33 +0000
commitba4840c52becf73c2749c9ef0f2f09ed0b9d5c7f (patch)
tree61b839884d66c9dd8269e26117aa4e4c995ad119 /vendor/google.golang.org
parent6e00d0000e54f21a4a393e67fd914bda4d394f4a (diff)
Update dependencies
Diffstat (limited to 'vendor/google.golang.org')
-rw-r--r--vendor/google.golang.org/api/gensupport/header.go22
-rw-r--r--vendor/google.golang.org/api/gensupport/jsonfloat.go57
-rw-r--r--vendor/google.golang.org/api/gensupport/retry.go14
-rw-r--r--vendor/google.golang.org/api/internal/settings.go14
-rw-r--r--vendor/google.golang.org/api/option/option.go14
-rw-r--r--vendor/google.golang.org/api/storage/v1/storage-gen.go46
-rw-r--r--vendor/google.golang.org/api/transport/dial.go53
-rw-r--r--vendor/google.golang.org/api/transport/dial_appengine.go34
-rw-r--r--vendor/google.golang.org/appengine/CONTRIBUTING.md90
-rw-r--r--vendor/google.golang.org/appengine/internal/api_classic.go159
-rw-r--r--vendor/google.golang.org/appengine/internal/identity_classic.go27
-rw-r--r--vendor/google.golang.org/appengine/internal/main.go15
-rw-r--r--vendor/google.golang.org/appengine/internal/main_vm.go6
-rw-r--r--vendor/google.golang.org/appengine/socket/socket_classic.go290
-rw-r--r--vendor/google.golang.org/grpc/call.go29
-rw-r--r--vendor/google.golang.org/grpc/clientconn.go9
-rw-r--r--vendor/google.golang.org/grpc/credentials/credentials.go4
-rw-r--r--vendor/google.golang.org/grpc/rpc_util.go24
-rw-r--r--vendor/google.golang.org/grpc/server.go58
-rw-r--r--vendor/google.golang.org/grpc/stats/handlers.go108
-rw-r--r--vendor/google.golang.org/grpc/stream.go39
-rw-r--r--vendor/google.golang.org/grpc/transport/http2_client.go23
-rw-r--r--vendor/google.golang.org/grpc/transport/http2_server.go27
-rw-r--r--vendor/google.golang.org/grpc/transport/transport.go10
24 files changed, 463 insertions, 709 deletions
diff --git a/vendor/google.golang.org/api/gensupport/header.go b/vendor/google.golang.org/api/gensupport/header.go
new file mode 100644
index 0000000..cb5e67c
--- /dev/null
+++ b/vendor/google.golang.org/api/gensupport/header.go
@@ -0,0 +1,22 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package gensupport
+
+import (
+ "fmt"
+ "runtime"
+ "strings"
+)
+
+// GoogleClientHeader returns the value to use for the x-goog-api-client
+// header, which is used internally by Google.
+func GoogleClientHeader(generatorVersion, clientElement string) string {
+ elts := []string{"gl-go/" + strings.Replace(runtime.Version(), " ", "_", -1)}
+ if clientElement != "" {
+ elts = append(elts, clientElement)
+ }
+ elts = append(elts, fmt.Sprintf("gdcl/%s", generatorVersion))
+ return strings.Join(elts, " ")
+}
diff --git a/vendor/google.golang.org/api/gensupport/jsonfloat.go b/vendor/google.golang.org/api/gensupport/jsonfloat.go
new file mode 100644
index 0000000..cb02335
--- /dev/null
+++ b/vendor/google.golang.org/api/gensupport/jsonfloat.go
@@ -0,0 +1,57 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package gensupport
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "math"
+)
+
+// JSONFloat64 is a float64 that supports proper unmarshaling of special float
+// values in JSON, according to
+// https://developers.google.com/protocol-buffers/docs/proto3#json. Although
+// that is a proto-to-JSON spec, it applies to all Google APIs.
+//
+// The jsonpb package
+// (https://github.com/golang/protobuf/blob/master/jsonpb/jsonpb.go) has
+// similar functionality, but only for direct translation from proto messages
+// to JSON.
+type JSONFloat64 float64
+
+func (f *JSONFloat64) UnmarshalJSON(data []byte) error {
+ var ff float64
+ if err := json.Unmarshal(data, &ff); err == nil {
+ *f = JSONFloat64(ff)
+ return nil
+ }
+ var s string
+ if err := json.Unmarshal(data, &s); err == nil {
+ switch s {
+ case "NaN":
+ ff = math.NaN()
+ case "Infinity":
+ ff = math.Inf(1)
+ case "-Infinity":
+ ff = math.Inf(-1)
+ default:
+ return fmt.Errorf("google.golang.org/api/internal: bad float string %q", s)
+ }
+ *f = JSONFloat64(ff)
+ return nil
+ }
+ return errors.New("google.golang.org/api/internal: data not float or string")
+}
diff --git a/vendor/google.golang.org/api/gensupport/retry.go b/vendor/google.golang.org/api/gensupport/retry.go
index 9023368..c60b3c3 100644
--- a/vendor/google.golang.org/api/gensupport/retry.go
+++ b/vendor/google.golang.org/api/gensupport/retry.go
@@ -1,3 +1,17 @@
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package gensupport
import (
diff --git a/vendor/google.golang.org/api/internal/settings.go b/vendor/google.golang.org/api/internal/settings.go
index 6e60e48..d7b9f57 100644
--- a/vendor/google.golang.org/api/internal/settings.go
+++ b/vendor/google.golang.org/api/internal/settings.go
@@ -1,3 +1,17 @@
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
// Package internal supports the options and transport packages.
package internal
diff --git a/vendor/google.golang.org/api/option/option.go b/vendor/google.golang.org/api/option/option.go
index f266919..4b14a2e 100644
--- a/vendor/google.golang.org/api/option/option.go
+++ b/vendor/google.golang.org/api/option/option.go
@@ -1,3 +1,17 @@
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
// Package option contains options for Google API clients.
package option
diff --git a/vendor/google.golang.org/api/storage/v1/storage-gen.go b/vendor/google.golang.org/api/storage/v1/storage-gen.go
index 0f1d094..849d52f 100644
--- a/vendor/google.golang.org/api/storage/v1/storage-gen.go
+++ b/vendor/google.golang.org/api/storage/v1/storage-gen.go
@@ -78,9 +78,10 @@ func New(client *http.Client) (*Service, error) {
}
type Service struct {
- client *http.Client
- BasePath string // API endpoint base URL
- UserAgent string // optional additional User-Agent fragment
+ client *http.Client
+ BasePath string // API endpoint base URL
+ UserAgent string // optional additional User-Agent fragment
+ GoogleClientHeaderElement string // client header fragment, for Google use only
BucketAccessControls *BucketAccessControlsService
@@ -102,6 +103,10 @@ func (s *Service) userAgent() string {
return googleapi.UserAgent + " " + s.UserAgent
}
+func (s *Service) clientHeader() string {
+ return gensupport.GoogleClientHeader("20170210", s.GoogleClientHeaderElement)
+}
+
func NewBucketAccessControlsService(s *Service) *BucketAccessControlsService {
rs := &BucketAccessControlsService{s: s}
return rs
@@ -1438,6 +1443,7 @@ func (c *BucketAccessControlsDeleteCall) doRequest(alt string) (*http.Response,
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}/acl/{entity}")
@@ -1556,6 +1562,7 @@ func (c *BucketAccessControlsGetCall) doRequest(alt string) (*http.Response, err
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -1693,6 +1700,7 @@ func (c *BucketAccessControlsInsertCall) doRequest(alt string) (*http.Response,
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucketaccesscontrol)
if err != nil {
@@ -1836,6 +1844,7 @@ func (c *BucketAccessControlsListCall) doRequest(alt string) (*http.Response, er
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -1968,6 +1977,7 @@ func (c *BucketAccessControlsPatchCall) doRequest(alt string) (*http.Response, e
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucketaccesscontrol)
if err != nil {
@@ -2112,6 +2122,7 @@ func (c *BucketAccessControlsUpdateCall) doRequest(alt string) (*http.Response,
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucketaccesscontrol)
if err != nil {
@@ -2268,6 +2279,7 @@ func (c *BucketsDeleteCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}")
@@ -2417,6 +2429,7 @@ func (c *BucketsGetCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -2625,6 +2638,7 @@ func (c *BucketsInsertCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucket)
if err != nil {
@@ -2851,6 +2865,7 @@ func (c *BucketsListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -3101,6 +3116,7 @@ func (c *BucketsPatchCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucket2)
if err != nil {
@@ -3370,6 +3386,7 @@ func (c *BucketsUpdateCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucket2)
if err != nil {
@@ -3567,6 +3584,7 @@ func (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
if err != nil {
@@ -3664,6 +3682,7 @@ func (c *DefaultObjectAccessControlsDeleteCall) doRequest(alt string) (*http.Res
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}/defaultObjectAcl/{entity}")
@@ -3782,6 +3801,7 @@ func (c *DefaultObjectAccessControlsGetCall) doRequest(alt string) (*http.Respon
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -3920,6 +3940,7 @@ func (c *DefaultObjectAccessControlsInsertCall) doRequest(alt string) (*http.Res
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
if err != nil {
@@ -4080,6 +4101,7 @@ func (c *DefaultObjectAccessControlsListCall) doRequest(alt string) (*http.Respo
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -4224,6 +4246,7 @@ func (c *DefaultObjectAccessControlsPatchCall) doRequest(alt string) (*http.Resp
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
if err != nil {
@@ -4368,6 +4391,7 @@ func (c *DefaultObjectAccessControlsUpdateCall) doRequest(alt string) (*http.Res
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
if err != nil {
@@ -4521,6 +4545,7 @@ func (c *ObjectAccessControlsDeleteCall) doRequest(alt string) (*http.Response,
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}/o/{object}/acl/{entity}")
@@ -4663,6 +4688,7 @@ func (c *ObjectAccessControlsGetCall) doRequest(alt string) (*http.Response, err
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -4824,6 +4850,7 @@ func (c *ObjectAccessControlsInsertCall) doRequest(alt string) (*http.Response,
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
if err != nil {
@@ -4991,6 +5018,7 @@ func (c *ObjectAccessControlsListCall) doRequest(alt string) (*http.Response, er
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -5147,6 +5175,7 @@ func (c *ObjectAccessControlsPatchCall) doRequest(alt string) (*http.Response, e
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
if err != nil {
@@ -5315,6 +5344,7 @@ func (c *ObjectAccessControlsUpdateCall) doRequest(alt string) (*http.Response,
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
if err != nil {
@@ -5511,6 +5541,7 @@ func (c *ObjectsComposeCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.composerequest)
if err != nil {
@@ -5823,6 +5854,7 @@ func (c *ObjectsCopyCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object)
if err != nil {
@@ -6131,6 +6163,7 @@ func (c *ObjectsDeleteCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}/o/{object}")
@@ -6331,6 +6364,7 @@ func (c *ObjectsGetCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -6673,6 +6707,7 @@ func (c *ObjectsInsertCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object)
if err != nil {
@@ -7005,6 +7040,7 @@ func (c *ObjectsListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
@@ -7274,6 +7310,7 @@ func (c *ObjectsPatchCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object2)
if err != nil {
@@ -7623,6 +7660,7 @@ func (c *ObjectsRewriteCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object)
if err != nil {
@@ -7955,6 +7993,7 @@ func (c *ObjectsUpdateCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object2)
if err != nil {
@@ -8233,6 +8272,7 @@ func (c *ObjectsWatchAllCall) doRequest(alt string) (*http.Response, error) {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
+ reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
if err != nil {
diff --git a/vendor/google.golang.org/api/transport/dial.go b/vendor/google.golang.org/api/transport/dial.go
index 9971eb8..a41ed0c 100644
--- a/vendor/google.golang.org/api/transport/dial.go
+++ b/vendor/google.golang.org/api/transport/dial.go
@@ -46,15 +46,18 @@ func NewHTTPClient(ctx context.Context, opts ...option.ClientOption) (*http.Clie
if o.GRPCConn != nil {
return nil, "", errors.New("unsupported gRPC connection specified")
}
- // TODO(djd): Set UserAgent on all outgoing requests.
+ // TODO(cbro): consider injecting the User-Agent even if an explicit HTTP client is provided?
if o.HTTPClient != nil {
return o.HTTPClient, o.Endpoint, nil
}
if o.APIKey != "" {
hc := &http.Client{
Transport: &gtransport.APIKey{
- Key: o.APIKey,
- Transport: http.DefaultTransport,
+ Key: o.APIKey,
+ Transport: userAgentTransport{
+ base: baseTransport(ctx),
+ userAgent: o.UserAgent,
+ },
},
}
return hc, o.Endpoint, nil
@@ -73,11 +76,53 @@ func NewHTTPClient(ctx context.Context, opts ...option.ClientOption) (*http.Clie
return nil, "", fmt.Errorf("google.DefaultTokenSource: %v", err)
}
}
- return oauth2.NewClient(ctx, o.TokenSource), o.Endpoint, nil
+ hc := &http.Client{
+ Transport: &oauth2.Transport{
+ Source: o.TokenSource,
+ Base: userAgentTransport{
+ base: baseTransport(ctx),
+ userAgent: o.UserAgent,
+ },
+ },
+ }
+ return hc, o.Endpoint, nil
+}
+
+type userAgentTransport struct {
+ userAgent string
+ base http.RoundTripper
+}
+
+func (t userAgentTransport) RoundTrip(req *http.Request) (*http.Response, error) {
+ rt := t.base
+ if rt == nil {
+ return nil, errors.New("transport: no Transport specified")
+ }
+ if t.userAgent == "" {
+ return rt.RoundTrip(req)
+ }
+ newReq := *req
+ newReq.Header = make(http.Header)
+ for k, vv := range req.Header {
+ newReq.Header[k] = vv
+ }
+ // TODO(cbro): append to existing User-Agent header?
+ newReq.Header["User-Agent"] = []string{t.userAgent}
+ return rt.RoundTrip(&newReq)
}
// Set at init time by dial_appengine.go. If nil, we're not on App Engine.
var appengineDialerHook func(context.Context) grpc.DialOption
+var appengineUrlfetchHook func(context.Context) http.RoundTripper
+
+// baseTransport returns the base HTTP transport.
+// On App Engine, this is urlfetch.Transport, otherwise it's http.DefaultTransport.
+func baseTransport(ctx context.Context) http.RoundTripper {
+ if appengineUrlfetchHook != nil {
+ return appengineUrlfetchHook(ctx)
+ }
+ return http.DefaultTransport
+}
// DialGRPC returns a GRPC connection for use communicating with a Google cloud
// service, configured with the given ClientOptions.
diff --git a/vendor/google.golang.org/api/transport/dial_appengine.go b/vendor/google.golang.org/api/transport/dial_appengine.go
deleted file mode 100644
index 201244d..0000000
--- a/vendor/google.golang.org/api/transport/dial_appengine.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// +build appengine
-
-package transport
-
-import (
- "net"
- "time"
-
- "golang.org/x/net/context"
- "google.golang.org/appengine/socket"
- "google.golang.org/grpc"
-)
-
-func init() {
- appengineDialerHook = func(ctx context.Context) grpc.DialOption {
- return grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
- return socket.DialTimeout(ctx, "tcp", addr, timeout)
- })
- }
-}
diff --git a/vendor/google.golang.org/appengine/CONTRIBUTING.md b/vendor/google.golang.org/appengine/CONTRIBUTING.md
new file mode 100644
index 0000000..ffc2985
--- /dev/null
+++ b/vendor/google.golang.org/appengine/CONTRIBUTING.md
@@ -0,0 +1,90 @@
+# Contributing
+
+1. Sign one of the contributor license agreements below.
+1. Get the package:
+
+ `go get -d google.golang.org/appengine`
+1. Change into the checked out source:
+
+ `cd $GOPATH/src/google.golang.org/appengine`
+1. Fork the repo.
+1. Set your fork as a remote:
+
+ `git remote add fork git@github.com:GITHUB_USERNAME/appengine.git`
+1. Make changes, commit to your fork.
+1. Send a pull request with your changes.
+ The first line of your commit message is conventionally a one-line summary of the change, prefixed by the primary affected package, and is used as the title of your pull request.
+
+# Testing
+
+## Running system tests
+
+Download and install the [Go App Engine SDK](https://cloud.google.com/appengine/docs/go/download). Make sure the `go_appengine` dir is in your `PATH`.
+
+Set the `APPENGINE_DEV_APPSERVER` environment variable to `/path/to/go_appengine/dev_appserver.py`.
+
+Run tests with `goapp test`:
+
+```
+goapp test -v google.golang.org/appengine/...
+```
+
+## Contributor License Agreements
+
+Before we can accept your pull requests you'll need to sign a Contributor
+License Agreement (CLA):
+
+- **If you are an individual writing original source code** and **you own the
+intellectual property**, then you'll need to sign an [individual CLA][indvcla].
+- **If you work for a company that wants to allow you to contribute your work**,
+then you'll need to sign a [corporate CLA][corpcla].
+
+You can sign these electronically (just scroll to the bottom). After that,
+we'll be able to accept your pull requests.
+
+## Contributor Code of Conduct
+
+As contributors and maintainers of this project,
+and in the interest of fostering an open and welcoming community,
+we pledge to respect all people who contribute through reporting issues,
+posting feature requests, updating documentation,
+submitting pull requests or patches, and other activities.
+
+We are committed to making participation in this project
+a harassment-free experience for everyone,
+regardless of level of experience, gender, gender identity and expression,
+sexual orientation, disability, personal appearance,
+body size, race, ethnicity, age, religion, or nationality.
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery
+* Personal attacks
+* Trolling or insulting/derogatory comments
+* Public or private harassment
+* Publishing other's private information,
+such as physical or electronic
+addresses, without explicit permission
+* Other unethical or unprofessional conduct.
+
+Project maintainers have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct.
+By adopting this Code of Conduct,
+project maintainers commit themselves to fairly and consistently
+applying these principles to every aspect of managing this project.
+Project maintainers who do not follow or enforce the Code of Conduct
+may be permanently removed from the project team.
+
+This code of conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community.
+
+Instances of abusive, harassing, or otherwise unacceptable behavior
+may be reported by opening an issue
+or contacting one or more of the project maintainers.
+
+This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
+available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
+
+[indvcla]: https://developers.google.com/open-source/cla/individual
+[corpcla]: https://developers.google.com/open-source/cla/corporate
diff --git a/vendor/google.golang.org/appengine/internal/api_classic.go b/vendor/google.golang.org/appengine/internal/api_classic.go
deleted file mode 100644
index 597f66e..0000000
--- a/vendor/google.golang.org/appengine/internal/api_classic.go
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright 2015 Google Inc. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-// +build appengine
-
-package internal
-
-import (
- "errors"
- "fmt"
- "net/http"
- "time"
-
- "appengine"
- "appengine_internal"
- basepb "appengine_internal/base"
-
- "github.com/golang/protobuf/proto"
- netcontext "golang.org/x/net/context"
-)
-
-var contextKey = "holds an appengine.Context"
-
-func fromContext(ctx netcontext.Context) appengine.Context {
- c, _ := ctx.Value(&contextKey).(appengine.Context)
- return c
-}
-
-// This is only for classic App Engine adapters.
-func ClassicContextFromContext(ctx netcontext.Context) appengine.Context {
- return fromContext(ctx)
-}
-
-func withContext(parent netcontext.Context, c appengine.Context) netcontext.Context {
- ctx := netcontext.WithValue(parent, &contextKey, c)
-
- s := &basepb.StringProto{}
- c.Call("__go__", "GetNamespace", &basepb.VoidProto{}, s, nil)
- if ns := s.GetValue(); ns != "" {
- ctx = NamespacedContext(ctx, ns)
- }
-
- return ctx
-}
-
-func IncomingHeaders(ctx netcontext.Context) http.Header {
- if c := fromContext(ctx); c != nil {
- if req, ok := c.Request().(*http.Request); ok {
- return req.Header
- }
- }
- return nil
-}
-
-func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context {
- c := appengine.NewContext(req)
- return withContext(parent, c)
-}
-
-type testingContext struct {
- appengine.Context
-
- req *http.Request
-}
-
-func (t *testingContext) FullyQualifiedAppID() string { return "dev~testcontext" }
-func (t *testingContext) Call(service, method string, _, _ appengine_internal.ProtoMessage, _ *appengine_internal.CallOptions) error {
- if service == "__go__" && method == "GetNamespace" {
- return nil
- }
- return fmt.Errorf("testingContext: unsupported Call")
-}
-func (t *testingContext) Request() interface{} { return t.req }
-
-func ContextForTesting(req *http.Request) netcontext.Context {
- return withContext(netcontext.Background(), &testingContext{req: req})
-}
-
-func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error {
- if ns := NamespaceFromContext(ctx); ns != "" {
- if fn, ok := NamespaceMods[service]; ok {
- fn(in, ns)
- }
- }
-
- if f, ctx, ok := callOverrideFromContext(ctx); ok {
- return f(ctx, service, method, in, out)
- }
-
- // Handle already-done contexts quickly.
- select {
- case <-ctx.Done():
- return ctx.Err()
- default:
- }
-
- c := fromContext(ctx)
- if c == nil {
- // Give a good error message rather than a panic lower down.
- return errors.New("not an App Engine context")
- }
-
- // Apply transaction modifications if we're in a transaction.
- if t := transactionFromContext(ctx); t != nil {
- if t.finished {
- return errors.New("transaction context has expired")
- }
- applyTransaction(in, &t.transaction)
- }
-
- var opts *appengine_internal.CallOptions
- if d, ok := ctx.Deadline(); ok {
- opts = &appengine_internal.CallOptions{
- Timeout: d.Sub(time.Now()),
- }
- }
-
- err := c.Call(service, method, in, out, opts)
- switch v := err.(type) {
- case *appengine_internal.APIError:
- return &APIError{
- Service: v.Service,
- Detail: v.Detail,
- Code: v.Code,
- }
- case *appengine_internal.CallError:
- return &CallError{
- Detail: v.Detail,
- Code: v.Code,
- Timeout: v.Timeout,
- }
- }
- return err
-}
-
-func handleHTTP(w http.ResponseWriter, r *http.Request) {
- panic("handleHTTP called; this should be impossible")
-}
-
-func logf(c appengine.Context, level int64, format string, args ...interface{}) {
- var fn func(format string, args ...interface{})
- switch level {
- case 0:
- fn = c.Debugf
- case 1:
- fn = c.Infof
- case 2:
- fn = c.Warningf
- case 3:
- fn = c.Errorf
- case 4:
- fn = c.Criticalf
- default:
- // This shouldn't happen.
- fn = c.Criticalf
- }
- fn(format, args...)
-}
diff --git a/vendor/google.golang.org/appengine/internal/identity_classic.go b/vendor/google.golang.org/appengine/internal/identity_classic.go
deleted file mode 100644
index e6b9227..0000000
--- a/vendor/google.golang.org/appengine/internal/identity_classic.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2015 Google Inc. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-// +build appengine
-
-package internal
-
-import (
- "appengine"
-
- netcontext "golang.org/x/net/context"
-)
-
-func DefaultVersionHostname(ctx netcontext.Context) string {
- return appengine.DefaultVersionHostname(fromContext(ctx))
-}
-
-func RequestID(ctx netcontext.Context) string { return appengine.RequestID(fromContext(ctx)) }
-func Datacenter(_ netcontext.Context) string { return appengine.Datacenter() }
-func ServerSoftware() string { return appengine.ServerSoftware() }
-func ModuleName(ctx netcontext.Context) string { return appengine.ModuleName(fromContext(ctx)) }
-func VersionID(ctx netcontext.Context) string { return appengine.VersionID(fromContext(ctx)) }
-func InstanceID() string { return appengine.InstanceID() }
-func IsDevAppServer() bool { return appengine.IsDevAppServer() }
-
-func fullyQualifiedAppID(ctx netcontext.Context) string { return fromContext(ctx).FullyQualifiedAppID() }
diff --git a/vendor/google.golang.org/appengine/internal/main.go b/vendor/google.golang.org/appengine/internal/main.go
deleted file mode 100644
index 4903616..0000000
--- a/vendor/google.golang.org/appengine/internal/main.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-// +build appengine
-
-package internal
-
-import (
- "appengine_internal"
-)
-
-func Main() {
- appengine_internal.Main()
-}
diff --git a/vendor/google.golang.org/appengine/internal/main_vm.go b/vendor/google.golang.org/appengine/internal/main_vm.go
index 57331ad..822e784 100644
--- a/vendor/google.golang.org/appengine/internal/main_vm.go
+++ b/vendor/google.golang.org/appengine/internal/main_vm.go
@@ -22,7 +22,11 @@ func Main() {
port = s
}
- if err := http.ListenAndServe(":"+port, http.HandlerFunc(handleHTTP)); err != nil {
+ host := ""
+ if IsDevAppServer() {
+ host = "127.0.0.1"
+ }
+ if err := http.ListenAndServe(host+":"+port, http.HandlerFunc(handleHTTP)); err != nil {
log.Fatalf("http.ListenAndServe: %v", err)
}
}
diff --git a/vendor/google.golang.org/appengine/socket/socket_classic.go b/vendor/google.golang.org/appengine/socket/socket_classic.go
deleted file mode 100644
index 0ad50e2..0000000
--- a/vendor/google.golang.org/appengine/socket/socket_classic.go
+++ /dev/null
@@ -1,290 +0,0 @@
-// Copyright 2012 Google Inc. All rights reserved.
-// Use of this source code is governed by the Apache 2.0
-// license that can be found in the LICENSE file.
-
-// +build appengine
-
-package socket
-
-import (
- "fmt"
- "io"
- "net"
- "strconv"
- "time"
-
- "github.com/golang/protobuf/proto"
- "golang.org/x/net/context"
- "google.golang.org/appengine/internal"
-
- pb "google.golang.org/appengine/internal/socket"
-)
-
-// Dial connects to the address addr on the network protocol.
-// The address format is host:port, where host may be a hostname or an IP address.
-// Known protocols are "tcp" and "udp".
-// The returned connection satisfies net.Conn, and is valid while ctx is valid;
-// if the connection is to be used after ctx becomes invalid, invoke SetContext
-// with the new context.
-func Dial(ctx context.Context, protocol, addr string) (*Conn, error) {
- return DialTimeout(ctx, protocol, addr, 0)
-}
-
-var ipFamilies = []pb.CreateSocketRequest_SocketFamily{
- pb.CreateSocketRequest_IPv4,
- pb.CreateSocketRequest_IPv6,
-}
-
-// DialTimeout is like Dial but takes a timeout.
-// The timeout includes name resolution, if required.
-func DialTimeout(ctx context.Context, protocol, addr string, timeout time.Duration) (*Conn, error) {
- dialCtx := ctx // Used for dialing and name resolution, but not stored in the *Conn.
- if timeout > 0 {
- var cancel context.CancelFunc
- dialCtx, cancel = context.WithTimeout(ctx, timeout)
- defer cancel()
- }
-
- host, portStr, err := net.SplitHostPort(addr)
- if err != nil {
- return nil, err
- }
- port, err := strconv.Atoi(portStr)
- if err != nil {
- return nil, fmt.Errorf("socket: bad port %q: %v", portStr, err)
- }
-
- var prot pb.CreateSocketRequest_SocketProtocol
- switch protocol {
- case "tcp":
- prot = pb.CreateSocketRequest_TCP
- case "udp":
- prot = pb.CreateSocketRequest_UDP
- default:
- return nil, fmt.Errorf("socket: unknown protocol %q", protocol)
- }
-
- packedAddrs, resolved, err := resolve(dialCtx, ipFamilies, host)
- if err != nil {
- return nil, fmt.Errorf("socket: failed resolving %q: %v", host, err)
- }
- if len(packedAddrs) == 0 {
- return nil, fmt.Errorf("no addresses for %q", host)
- }
-
- packedAddr := packedAddrs[0] // use first address
- fam := pb.CreateSocketRequest_IPv4
- if len(packedAddr) == net.IPv6len {
- fam = pb.CreateSocketRequest_IPv6
- }
-
- req := &pb.CreateSocketRequest{
- Family: fam.Enum(),
- Protocol: prot.Enum(),
- RemoteIp: &pb.AddressPort{
- Port: proto.Int32(int32(port)),
- PackedAddress: packedAddr,
- },
- }
- if resolved {
- req.RemoteIp.HostnameHint = &host
- }
- res := &pb.CreateSocketReply{}
- if err := internal.Call(dialCtx, "remote_socket", "CreateSocket", req, res); err != nil {
- return nil, err
- }
-
- return &Conn{
- ctx: ctx,
- desc: res.GetSocketDescriptor(),
- prot: prot,
- local: res.ProxyExternalIp,
- remote: req.RemoteIp,
- }, nil
-}
-
-// LookupIP returns the given host's IP addresses.
-func LookupIP(ctx context.Context, host string) (addrs []net.IP, err error) {
- packedAddrs, _, err := resolve(ctx, ipFamilies, host)
- if err != nil {
- return nil, fmt.Errorf("socket: failed resolving %q: %v", host, err)
- }
- addrs = make([]net.IP, len(packedAddrs))
- for i, pa := range packedAddrs {
- addrs[i] = net.IP(pa)
- }
- return addrs, nil
-}
-
-func resolve(ctx context.Context, fams []pb.CreateSocketRequest_SocketFamily, host string) ([][]byte, bool, error) {
- // Check if it's an IP address.
- if ip := net.ParseIP(host); ip != nil {
- if ip := ip.To4(); ip != nil {
- return [][]byte{ip}, false, nil
- }
- return [][]byte{ip}, false, nil
- }
-
- req := &pb.ResolveRequest{
- Name: &host,
- AddressFamilies: fams,
- }
- res := &pb.ResolveReply{}
- if err := internal.Call(ctx, "remote_socket", "Resolve", req, res); err != nil {
- // XXX: need to map to pb.ResolveReply_ErrorCode?
- return nil, false, err
- }
- return res.PackedAddress, true, nil
-}
-
-// withDeadline is like context.WithDeadline, except it ignores the zero deadline.
-func withDeadline(parent context.Context, deadline time.Time) (context.Context, context.CancelFunc) {
- if deadline.IsZero() {
- return parent, func() {}
- }
- return context.WithDeadline(parent, deadline)
-}
-
-// Conn represents a socket connection.
-// It implements net.Conn.
-type Conn struct {
- ctx context.Context
- desc string
- offset int64
-
- prot pb.CreateSocketRequest_SocketProtocol
- local, remote *pb.AddressPort
-
- readDeadline, writeDeadline time.Time // optional
-}
-
-// SetContext sets the context that is used by this Conn.
-// It is usually used only when using a Conn that was created in a different context,
-// such as when a connection is created during a warmup request but used while
-// servicing a user request.
-func (cn *Conn) SetContext(ctx context.Context) {
- cn.ctx = ctx
-}
-
-func (cn *Conn) Read(b []byte) (n int, err error) {
- const maxRead = 1 << 20
- if len(b) > maxRead {
- b = b[:maxRead]
- }
-
- req := &pb.ReceiveRequest{
- SocketDescriptor: &cn.desc,
- DataSize: proto.Int32(int32(len(b))),
- }
- res := &pb.ReceiveReply{}
- if !cn.readDeadline.IsZero() {
- req.TimeoutSeconds = proto.Float64(cn.readDeadline.Sub(time.Now()).Seconds())
- }
- ctx, cancel := withDeadline(cn.ctx, cn.readDeadline)
- defer cancel()
- if err := internal.Call(ctx, "remote_socket", "Receive", req, res); err != nil {
- return 0, err
- }
- if len(res.Data) == 0 {
- return 0, io.EOF
- }
- if len(res.Data) > len(b) {
- return 0, fmt.Errorf("socket: internal error: read too much data: %d > %d", len(res.Data), len(b))
- }
- return copy(b, res.Data), nil
-}
-
-func (cn *Conn) Write(b []byte) (n int, err error) {
- const lim = 1 << 20 // max per chunk
-
- for n < len(b) {
- chunk := b[n:]
- if len(chunk) > lim {
- chunk = chunk[:lim]
- }
-
- req := &pb.SendRequest{
- SocketDescriptor: &cn.desc,
- Data: chunk,
- StreamOffset: &cn.offset,
- }
- res := &pb.SendReply{}
- if !cn.writeDeadline.IsZero() {
- req.TimeoutSeconds = proto.Float64(cn.writeDeadline.Sub(time.Now()).Seconds())
- }
- ctx, cancel := withDeadline(cn.ctx, cn.writeDeadline)
- defer cancel()
- if err = internal.Call(ctx, "remote_socket", "Send", req, res); err != nil {
- // assume zero bytes were sent in this RPC
- break
- }
- n += int(res.GetDataSent())
- cn.offset += int64(res.GetDataSent())
- }
-
- return
-}
-
-func (cn *Conn) Close() error {
- req := &pb.CloseRequest{
- SocketDescriptor: &cn.desc,
- }
- res := &pb.CloseReply{}
- if err := internal.Call(cn.ctx, "remote_socket", "Close", req, res); err != nil {
- return err
- }
- cn.desc = "CLOSED"
- return nil
-}
-
-func addr(prot pb.CreateSocketRequest_SocketProtocol, ap *pb.AddressPort) net.Addr {
- if ap == nil {
- return nil
- }
- switch prot {
- case pb.CreateSocketRequest_TCP:
- return &net.TCPAddr{
- IP: net.IP(ap.PackedAddress),
- Port: int(*ap.Port),
- }
- case pb.CreateSocketRequest_UDP:
- return &net.UDPAddr{
- IP: net.IP(ap.PackedAddress),
- Port: int(*ap.Port),
- }
- }
- panic("unknown protocol " + prot.String())
-}
-
-func (cn *Conn) LocalAddr() net.Addr { return addr(cn.prot, cn.local) }
-func (cn *Conn) RemoteAddr() net.Addr { return addr(cn.prot, cn.remote) }
-
-func (cn *Conn) SetDeadline(t time.Time) error {
- cn.readDeadline = t
- cn.writeDeadline = t
- return nil
-}
-
-func (cn *Conn) SetReadDeadline(t time.Time) error {
- cn.readDeadline = t
- return nil
-}
-
-func (cn *Conn) SetWriteDeadline(t time.Time) error {
- cn.writeDeadline = t
- return nil
-}
-
-// KeepAlive signals that the connection is still in use.
-// It may be called to prevent the socket being closed due to inactivity.
-func (cn *Conn) KeepAlive() error {
- req := &pb.GetSocketNameRequest{
- SocketDescriptor: &cn.desc,
- }
- res := &pb.GetSocketNameReply{}
- return internal.Call(cn.ctx, "remote_socket", "GetSocketName", req, res)
-}
-
-func init() {
- internal.RegisterErrorCodeMap("remote_socket", pb.RemoteSocketServiceError_ErrorCode_name)
-}
diff --git a/vendor/google.golang.org/grpc/call.go b/vendor/google.golang.org/grpc/call.go
index 4d8023d..81b52be 100644
--- a/vendor/google.golang.org/grpc/call.go
+++ b/vendor/google.golang.org/grpc/call.go
@@ -42,6 +42,7 @@ import (
"golang.org/x/net/context"
"golang.org/x/net/trace"
"google.golang.org/grpc/codes"
+ "google.golang.org/grpc/peer"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/transport"
)
@@ -66,7 +67,7 @@ func recvResponse(ctx context.Context, dopts dialOptions, t transport.ClientTran
}
p := &parser{r: stream}
var inPayload *stats.InPayload
- if stats.On() {
+ if dopts.copts.StatsHandler != nil {
inPayload = &stats.InPayload{
Client: true,
}
@@ -82,14 +83,17 @@ func recvResponse(ctx context.Context, dopts dialOptions, t transport.ClientTran
if inPayload != nil && err == io.EOF && stream.StatusCode() == codes.OK {
// TODO in the current implementation, inTrailer may be handled before inPayload in some cases.
// Fix the order if necessary.
- stats.HandleRPC(ctx, inPayload)
+ dopts.copts.StatsHandler.HandleRPC(ctx, inPayload)
}
c.trailerMD = stream.Trailer()
+ if peer, ok := peer.FromContext(stream.Context()); ok {
+ c.peer = peer
+ }
return nil
}
// sendRequest writes out various information of an RPC such as Context and Message.
-func sendRequest(ctx context.Context, codec Codec, compressor Compressor, callHdr *transport.CallHdr, t transport.ClientTransport, args interface{}, opts *transport.Options) (_ *transport.Stream, err error) {
+func sendRequest(ctx context.Context, dopts dialOptions, compressor Compressor, callHdr *transport.CallHdr, t transport.ClientTransport, args interface{}, opts *transport.Options) (_ *transport.Stream, err error) {
stream, err := t.NewStream(ctx, callHdr)
if err != nil {
return nil, err
@@ -109,19 +113,19 @@ func sendRequest(ctx context.Context, codec Codec, compressor Compressor, callHd
if compressor != nil {
cbuf = new(bytes.Buffer)
}
- if stats.On() {
+ if dopts.copts.StatsHandler != nil {
outPayload = &stats.OutPayload{
Client: true,
}
}
- outBuf, err := encode(codec, args, compressor, cbuf, outPayload)
+ outBuf, err := encode(dopts.codec, args, compressor, cbuf, outPayload)
if err != nil {
return nil, Errorf(codes.Internal, "grpc: %v", err)
}
err = t.Write(stream, outBuf, opts)
if err == nil && outPayload != nil {
outPayload.SentTime = time.Now()
- stats.HandleRPC(ctx, outPayload)
+ dopts.copts.StatsHandler.HandleRPC(ctx, outPayload)
}
// t.NewStream(...) could lead to an early rejection of the RPC (e.g., the service/method
// does not exist.) so that t.Write could get io.EOF from wait(...). Leave the following
@@ -179,23 +183,24 @@ func invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
}
}()
}
- if stats.On() {
- ctx = stats.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method})
+ sh := cc.dopts.copts.StatsHandler
+ if sh != nil {
+ ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method})
begin := &stats.Begin{
Client: true,
BeginTime: time.Now(),
FailFast: c.failFast,
}
- stats.HandleRPC(ctx, begin)
+ sh.HandleRPC(ctx, begin)
}
defer func() {
- if stats.On() {
+ if sh != nil {
end := &stats.End{
Client: true,
EndTime: time.Now(),
Error: e,
}
- stats.HandleRPC(ctx, end)
+ sh.HandleRPC(ctx, end)
}
}()
topts := &transport.Options{
@@ -241,7 +246,7 @@ func invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
if c.traceInfo.tr != nil {
c.traceInfo.tr.LazyLog(&payload{sent: true, msg: args}, true)
}
- stream, err = sendRequest(ctx, cc.dopts.codec, cc.dopts.cp, callHdr, t, args, topts)
+ stream, err = sendRequest(ctx, cc.dopts, cc.dopts.cp, callHdr, t, args, topts)
if err != nil {
if put != nil {
put()
diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go
index aa6b63d..146166a 100644
--- a/vendor/google.golang.org/grpc/clientconn.go
+++ b/vendor/google.golang.org/grpc/clientconn.go
@@ -45,6 +45,7 @@ import (
"golang.org/x/net/trace"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog"
+ "google.golang.org/grpc/stats"
"google.golang.org/grpc/transport"
)
@@ -222,6 +223,14 @@ func WithDialer(f func(string, time.Duration) (net.Conn, error)) DialOption {
}
}
+// WithStatsHandler returns a DialOption that specifies the stats handler
+// for all the RPCs and underlying network connections in this ClientConn.
+func WithStatsHandler(h stats.Handler) DialOption {
+ return func(o *dialOptions) {
+ o.copts.StatsHandler = h
+ }
+}
+
// FailOnNonTempDialError returns a DialOption that specified if gRPC fails on non-temporary dial errors.
// If f is true, and dialer returns a non-temporary error, gRPC will fail the connection to the network
// address and won't try to reconnect.
diff --git a/vendor/google.golang.org/grpc/credentials/credentials.go b/vendor/google.golang.org/grpc/credentials/credentials.go
index 5555ef0..4d45c3e 100644
--- a/vendor/google.golang.org/grpc/credentials/credentials.go
+++ b/vendor/google.golang.org/grpc/credentials/credentials.go
@@ -165,9 +165,7 @@ func (c *tlsCreds) ClientHandshake(ctx context.Context, addr string, rawConn net
case <-ctx.Done():
return nil, nil, ctx.Err()
}
- // TODO(zhaoq): Omit the auth info for client now. It is more for
- // information than anything else.
- return conn, nil, nil
+ return conn, TLSInfo{conn.ConnectionState()}, nil
}
func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) {
diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go
index 2619d39..da88dad 100644
--- a/vendor/google.golang.org/grpc/rpc_util.go
+++ b/vendor/google.golang.org/grpc/rpc_util.go
@@ -48,6 +48,7 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
+ "google.golang.org/grpc/peer"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/transport"
)
@@ -140,6 +141,7 @@ type callInfo struct {
failFast bool
headerMD metadata.MD
trailerMD metadata.MD
+ peer *peer.Peer
traceInfo traceInfo // in trace.go
}
@@ -183,6 +185,14 @@ func Trailer(md *metadata.MD) CallOption {
})
}
+// Peer returns a CallOption that retrieves peer information for a
+// unary RPC.
+func Peer(peer *peer.Peer) CallOption {
+ return afterCall(func(c *callInfo) {
+ *peer = *c.peer
+ })
+}
+
// FailFast configures the action to take when an RPC is attempted on broken
// connections or unreachable servers. If failfast is true, the RPC will fail
// immediately. Otherwise, the RPC client will block the call until a
@@ -486,17 +496,17 @@ type MethodConfig struct {
// then the other will be used. If neither is set, then the RPC has no deadline.
Timeout time.Duration
// MaxReqSize is the maximum allowed payload size for an individual request in a
- // stream (client->server) in bytes. The size which is measured is the serialized,
- // uncompressed payload in bytes. The actual value used is the minumum of the value
- // specified here and the value set by the application via the gRPC client API. If
- // either one is not set, then the other will be used. If neither is set, then the
- // built-in default is used.
+ // stream (client->server) in bytes. The size which is measured is the serialized
+ // payload after per-message compression (but before stream compression) in bytes.
+ // The actual value used is the minumum of the value specified here and the value set
+ // by the application via the gRPC client API. If either one is not set, then the other
+ // will be used. If neither is set, then the built-in default is used.
// TODO: support this.
- MaxReqSize uint64
+ MaxReqSize uint32
// MaxRespSize is the maximum allowed payload size for an individual response in a
// stream (server->client) in bytes.
// TODO: support this.
- MaxRespSize uint64
+ MaxRespSize uint32
}
// ServiceConfig is provided by the service provider and contains parameters for how
diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go
index b52a563..985226d 100644
--- a/vendor/google.golang.org/grpc/server.go
+++ b/vendor/google.golang.org/grpc/server.go
@@ -113,6 +113,7 @@ type options struct {
unaryInt UnaryServerInterceptor
streamInt StreamServerInterceptor
inTapHandle tap.ServerInHandle
+ statsHandler stats.Handler
maxConcurrentStreams uint32
useHandlerImpl bool // use http.Handler-based server
}
@@ -200,6 +201,13 @@ func InTapHandle(h tap.ServerInHandle) ServerOption {
}
}
+// StatsHandler returns a ServerOption that sets the stats handler for the server.
+func StatsHandler(h stats.Handler) ServerOption {
+ return func(o *options) {
+ o.statsHandler = h
+ }
+}
+
// NewServer creates a gRPC server which has no service registered and has not
// started to accept requests yet.
func NewServer(opt ...ServerOption) *Server {
@@ -438,9 +446,10 @@ func (s *Server) handleRawConn(rawConn net.Conn) {
// transport.NewServerTransport).
func (s *Server) serveHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) {
config := &transport.ServerConfig{
- MaxStreams: s.opts.maxConcurrentStreams,
- AuthInfo: authInfo,
- InTapHandle: s.opts.inTapHandle,
+ MaxStreams: s.opts.maxConcurrentStreams,
+ AuthInfo: authInfo,
+ InTapHandle: s.opts.inTapHandle,
+ StatsHandler: s.opts.statsHandler,
}
st, err := transport.NewServerTransport("http2", c, config)
if err != nil {
@@ -567,7 +576,7 @@ func (s *Server) sendResponse(t transport.ServerTransport, stream *transport.Str
if cp != nil {
cbuf = new(bytes.Buffer)
}
- if stats.On() {
+ if s.opts.statsHandler != nil {
outPayload = &stats.OutPayload{}
}
p, err := encode(s.opts.codec, msg, cp, cbuf, outPayload)
@@ -584,27 +593,28 @@ func (s *Server) sendResponse(t transport.ServerTransport, stream *transport.Str
err = t.Write(stream, p, opts)
if err == nil && outPayload != nil {
outPayload.SentTime = time.Now()
- stats.HandleRPC(stream.Context(), outPayload)
+ s.opts.statsHandler.HandleRPC(stream.Context(), outPayload)
}
return err
}
func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, md *MethodDesc, trInfo *traceInfo) (err error) {
- if stats.On() {
+ sh := s.opts.statsHandler
+ if sh != nil {
begin := &stats.Begin{
BeginTime: time.Now(),
}
- stats.HandleRPC(stream.Context(), begin)
+ sh.HandleRPC(stream.Context(), begin)
}
defer func() {
- if stats.On() {
+ if sh != nil {
end := &stats.End{
EndTime: time.Now(),
}
if err != nil && err != io.EOF {
end.Error = toRPCErr(err)
}
- stats.HandleRPC(stream.Context(), end)
+ sh.HandleRPC(stream.Context(), end)
}
}()
if trInfo != nil {
@@ -665,7 +675,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
}
}
var inPayload *stats.InPayload
- if stats.On() {
+ if sh != nil {
inPayload = &stats.InPayload{
RecvTime: time.Now(),
}
@@ -699,7 +709,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
inPayload.Payload = v
inPayload.Data = req
inPayload.Length = len(req)
- stats.HandleRPC(stream.Context(), inPayload)
+ sh.HandleRPC(stream.Context(), inPayload)
}
if trInfo != nil {
trInfo.tr.LazyLog(&payload{sent: false, msg: v}, true)
@@ -756,35 +766,37 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
}
func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, sd *StreamDesc, trInfo *traceInfo) (err error) {
- if stats.On() {
+ sh := s.opts.statsHandler
+ if sh != nil {
begin := &stats.Begin{
BeginTime: time.Now(),
}
- stats.HandleRPC(stream.Context(), begin)
+ sh.HandleRPC(stream.Context(), begin)
}
defer func() {
- if stats.On() {
+ if sh != nil {
end := &stats.End{
EndTime: time.Now(),
}
if err != nil && err != io.EOF {
end.Error = toRPCErr(err)
}
- stats.HandleRPC(stream.Context(), end)
+ sh.HandleRPC(stream.Context(), end)
}
}()
if s.opts.cp != nil {
stream.SetSendCompress(s.opts.cp.Type())
}
ss := &serverStream{
- t: t,
- s: stream,
- p: &parser{r: stream},
- codec: s.opts.codec,
- cp: s.opts.cp,
- dc: s.opts.dc,
- maxMsgSize: s.opts.maxMsgSize,
- trInfo: trInfo,
+ t: t,
+ s: stream,
+ p: &parser{r: stream},
+ codec: s.opts.codec,
+ cp: s.opts.cp,
+ dc: s.opts.dc,
+ maxMsgSize: s.opts.maxMsgSize,
+ trInfo: trInfo,
+ statsHandler: sh,
}
if ss.cp != nil {
ss.cbuf = new(bytes.Buffer)
diff --git a/vendor/google.golang.org/grpc/stats/handlers.go b/vendor/google.golang.org/grpc/stats/handlers.go
index ce47786..26e1a8e 100644
--- a/vendor/google.golang.org/grpc/stats/handlers.go
+++ b/vendor/google.golang.org/grpc/stats/handlers.go
@@ -35,10 +35,8 @@ package stats
import (
"net"
- "sync/atomic"
"golang.org/x/net/context"
- "google.golang.org/grpc/grpclog"
)
// ConnTagInfo defines the relevant information needed by connection context tagger.
@@ -56,91 +54,23 @@ type RPCTagInfo struct {
FullMethodName string
}
-var (
- on = new(int32)
- rpcHandler func(context.Context, RPCStats)
- connHandler func(context.Context, ConnStats)
- connTagger func(context.Context, *ConnTagInfo) context.Context
- rpcTagger func(context.Context, *RPCTagInfo) context.Context
-)
-
-// HandleRPC processes the RPC stats using the rpc handler registered by the user.
-func HandleRPC(ctx context.Context, s RPCStats) {
- if rpcHandler == nil {
- return
- }
- rpcHandler(ctx, s)
-}
-
-// RegisterRPCHandler registers the user handler function for RPC stats processing.
-// It should be called only once. The later call will overwrite the former value if it is called multiple times.
-// This handler function will be called to process the rpc stats.
-func RegisterRPCHandler(f func(context.Context, RPCStats)) {
- rpcHandler = f
-}
-
-// HandleConn processes the stats using the call back function registered by user.
-func HandleConn(ctx context.Context, s ConnStats) {
- if connHandler == nil {
- return
- }
- connHandler(ctx, s)
-}
-
-// RegisterConnHandler registers the user handler function for conn stats.
-// It should be called only once. The later call will overwrite the former value if it is called multiple times.
-// This handler function will be called to process the conn stats.
-func RegisterConnHandler(f func(context.Context, ConnStats)) {
- connHandler = f
-}
-
-// TagConn calls user registered connection context tagger.
-func TagConn(ctx context.Context, info *ConnTagInfo) context.Context {
- if connTagger == nil {
- return ctx
- }
- return connTagger(ctx, info)
-}
-
-// RegisterConnTagger registers the user connection context tagger function.
-// The connection context tagger can attach some information to the given context.
-// The returned context will be used for stats handling.
-// For conn stats handling, the context used in connHandler for this
-// connection will be derived from the context returned.
-// For RPC stats handling,
-// - On server side, the context used in rpcHandler for all RPCs on this
-// connection will be derived from the context returned.
-// - On client side, the context is not derived from the context returned.
-func RegisterConnTagger(t func(context.Context, *ConnTagInfo) context.Context) {
- connTagger = t
-}
-
-// TagRPC calls the user registered RPC context tagger.
-func TagRPC(ctx context.Context, info *RPCTagInfo) context.Context {
- if rpcTagger == nil {
- return ctx
- }
- return rpcTagger(ctx, info)
-}
-
-// RegisterRPCTagger registers the user RPC context tagger function.
-// The RPC context tagger can attach some information to the given context.
-// The context used in stats rpcHandler for this RPC will be derived from the
-// context returned.
-func RegisterRPCTagger(t func(context.Context, *RPCTagInfo) context.Context) {
- rpcTagger = t
-}
-
-// Start starts the stats collection and processing if there is a registered stats handle.
-func Start() {
- if rpcHandler == nil && connHandler == nil {
- grpclog.Println("rpcHandler and connHandler are both nil when starting stats. Stats is not started")
- return
- }
- atomic.StoreInt32(on, 1)
-}
-
-// On indicates whether the stats collection and processing is on.
-func On() bool {
- return atomic.CompareAndSwapInt32(on, 1, 1)
+// Handler defines the interface for the related stats handling (e.g., RPCs, connections).
+type Handler interface {
+ // TagRPC can attach some information to the given context.
+ // The returned context is used in the rest lifetime of the RPC.
+ TagRPC(context.Context, *RPCTagInfo) context.Context
+ // HandleRPC processes the RPC stats.
+ HandleRPC(context.Context, RPCStats)
+
+ // TagConn can attach some information to the given context.
+ // The returned context will be used for stats handling.
+ // For conn stats handling, the context used in HandleConn for this
+ // connection will be derived from the context returned.
+ // For RPC stats handling,
+ // - On server side, the context used in HandleRPC for all RPCs on this
+ // connection will be derived from the context returned.
+ // - On client side, the context is not derived from the context returned.
+ TagConn(context.Context, *ConnTagInfo) context.Context
+ // HandleConn processes the Conn stats.
+ HandleConn(context.Context, ConnStats)
}
diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go
index d3a4deb..bb468dc 100644
--- a/vendor/google.golang.org/grpc/stream.go
+++ b/vendor/google.golang.org/grpc/stream.go
@@ -151,23 +151,24 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
}
}()
}
- if stats.On() {
- ctx = stats.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method})
+ sh := cc.dopts.copts.StatsHandler
+ if sh != nil {
+ ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method})
begin := &stats.Begin{
Client: true,
BeginTime: time.Now(),
FailFast: c.failFast,
}
- stats.HandleRPC(ctx, begin)
+ sh.HandleRPC(ctx, begin)
}
defer func() {
- if err != nil && stats.On() {
+ if err != nil && sh != nil {
// Only handle end stats if err != nil.
end := &stats.End{
Client: true,
Error: err,
}
- stats.HandleRPC(ctx, end)
+ sh.HandleRPC(ctx, end)
}
}()
gopts := BalancerGetOptions{
@@ -223,7 +224,8 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
tracing: EnableTracing,
trInfo: trInfo,
- statsCtx: ctx,
+ statsCtx: ctx,
+ statsHandler: cc.dopts.copts.StatsHandler,
}
if cc.dopts.cp != nil {
cs.cbuf = new(bytes.Buffer)
@@ -281,7 +283,8 @@ type clientStream struct {
// statsCtx keeps the user context for stats handling.
// All stats collection should use the statsCtx (instead of the stream context)
// so that all the generated stats for a particular RPC can be associated in the processing phase.
- statsCtx context.Context
+ statsCtx context.Context
+ statsHandler stats.Handler
}
func (cs *clientStream) Context() context.Context {
@@ -335,7 +338,7 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
err = toRPCErr(err)
}()
var outPayload *stats.OutPayload
- if stats.On() {
+ if cs.statsHandler != nil {
outPayload = &stats.OutPayload{
Client: true,
}
@@ -352,14 +355,14 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
err = cs.t.Write(cs.s, out, &transport.Options{Last: false})
if err == nil && outPayload != nil {
outPayload.SentTime = time.Now()
- stats.HandleRPC(cs.statsCtx, outPayload)
+ cs.statsHandler.HandleRPC(cs.statsCtx, outPayload)
}
return err
}
func (cs *clientStream) RecvMsg(m interface{}) (err error) {
defer func() {
- if err != nil && stats.On() {
+ if err != nil && cs.statsHandler != nil {
// Only generate End if err != nil.
// If err == nil, it's not the last RecvMsg.
// The last RecvMsg gets either an RPC error or io.EOF.
@@ -370,11 +373,11 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) {
if err != io.EOF {
end.Error = toRPCErr(err)
}
- stats.HandleRPC(cs.statsCtx, end)
+ cs.statsHandler.HandleRPC(cs.statsCtx, end)
}
}()
var inPayload *stats.InPayload
- if stats.On() {
+ if cs.statsHandler != nil {
inPayload = &stats.InPayload{
Client: true,
}
@@ -395,7 +398,7 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) {
cs.mu.Unlock()
}
if inPayload != nil {
- stats.HandleRPC(cs.statsCtx, inPayload)
+ cs.statsHandler.HandleRPC(cs.statsCtx, inPayload)
}
if !cs.desc.ClientStreams || cs.desc.ServerStreams {
return
@@ -520,6 +523,8 @@ type serverStream struct {
statusDesc string
trInfo *traceInfo
+ statsHandler stats.Handler
+
mu sync.Mutex // protects trInfo.tr after the service handler runs.
}
@@ -562,7 +567,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) {
}
}()
var outPayload *stats.OutPayload
- if stats.On() {
+ if ss.statsHandler != nil {
outPayload = &stats.OutPayload{}
}
out, err := encode(ss.codec, m, ss.cp, ss.cbuf, outPayload)
@@ -580,7 +585,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) {
}
if outPayload != nil {
outPayload.SentTime = time.Now()
- stats.HandleRPC(ss.s.Context(), outPayload)
+ ss.statsHandler.HandleRPC(ss.s.Context(), outPayload)
}
return nil
}
@@ -601,7 +606,7 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) {
}
}()
var inPayload *stats.InPayload
- if stats.On() {
+ if ss.statsHandler != nil {
inPayload = &stats.InPayload{}
}
if err := recv(ss.p, ss.codec, ss.s, ss.dc, m, ss.maxMsgSize, inPayload); err != nil {
@@ -614,7 +619,7 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) {
return toRPCErr(err)
}
if inPayload != nil {
- stats.HandleRPC(ss.s.Context(), inPayload)
+ ss.statsHandler.HandleRPC(ss.s.Context(), inPayload)
}
return nil
}
diff --git a/vendor/google.golang.org/grpc/transport/http2_client.go b/vendor/google.golang.org/grpc/transport/http2_client.go
index 605b1e5..892f8ba 100644
--- a/vendor/google.golang.org/grpc/transport/http2_client.go
+++ b/vendor/google.golang.org/grpc/transport/http2_client.go
@@ -99,6 +99,8 @@ type http2Client struct {
creds []credentials.PerRPCCredentials
+ statsHandler stats.Handler
+
mu sync.Mutex // guard the following variables
state transportState // the state of underlying connection
activeStreams map[uint32]*Stream
@@ -208,16 +210,17 @@ func newHTTP2Client(ctx context.Context, addr TargetInfo, opts ConnectOptions) (
creds: opts.PerRPCCredentials,
maxStreams: math.MaxInt32,
streamSendQuota: defaultWindowSize,
+ statsHandler: opts.StatsHandler,
}
- if stats.On() {
- t.ctx = stats.TagConn(t.ctx, &stats.ConnTagInfo{
+ if t.statsHandler != nil {
+ t.ctx = t.statsHandler.TagConn(t.ctx, &stats.ConnTagInfo{
RemoteAddr: t.remoteAddr,
LocalAddr: t.localAddr,
})
connBegin := &stats.ConnBegin{
Client: true,
}
- stats.HandleConn(t.ctx, connBegin)
+ t.statsHandler.HandleConn(t.ctx, connBegin)
}
// Start the reader goroutine for incoming message. Each transport has
// a dedicated goroutine which reads HTTP2 frame from network. Then it
@@ -470,7 +473,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
return nil, connectionErrorf(true, err, "transport: %v", err)
}
}
- if stats.On() {
+ if t.statsHandler != nil {
outHeader := &stats.OutHeader{
Client: true,
WireLength: bufLen,
@@ -479,7 +482,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
LocalAddr: t.localAddr,
Compression: callHdr.SendCompress,
}
- stats.HandleRPC(s.clientStatsCtx, outHeader)
+ t.statsHandler.HandleRPC(s.clientStatsCtx, outHeader)
}
t.writableChan <- 0
return s, nil
@@ -559,11 +562,11 @@ func (t *http2Client) Close() (err error) {
s.mu.Unlock()
s.write(recvMsg{err: ErrConnClosing})
}
- if stats.On() {
+ if t.statsHandler != nil {
connEnd := &stats.ConnEnd{
Client: true,
}
- stats.HandleConn(t.ctx, connEnd)
+ t.statsHandler.HandleConn(t.ctx, connEnd)
}
return
}
@@ -911,19 +914,19 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
endStream := frame.StreamEnded()
var isHeader bool
defer func() {
- if stats.On() {
+ if t.statsHandler != nil {
if isHeader {
inHeader := &stats.InHeader{
Client: true,
WireLength: int(frame.Header().Length),
}
- stats.HandleRPC(s.clientStatsCtx, inHeader)
+ t.statsHandler.HandleRPC(s.clientStatsCtx, inHeader)
} else {
inTrailer := &stats.InTrailer{
Client: true,
WireLength: int(frame.Header().Length),
}
- stats.HandleRPC(s.clientStatsCtx, inTrailer)
+ t.statsHandler.HandleRPC(s.clientStatsCtx, inTrailer)
}
}
}()
diff --git a/vendor/google.golang.org/grpc/transport/http2_server.go b/vendor/google.golang.org/grpc/transport/http2_server.go
index 316188e..a095dd0 100644
--- a/vendor/google.golang.org/grpc/transport/http2_server.go
+++ b/vendor/google.golang.org/grpc/transport/http2_server.go
@@ -88,6 +88,8 @@ type http2Server struct {
// sendQuotaPool provides flow control to outbound message.
sendQuotaPool *quotaPool
+ stats stats.Handler
+
mu sync.Mutex // guard the following
state transportState
activeStreams map[uint32]*Stream
@@ -146,14 +148,15 @@ func newHTTP2Server(conn net.Conn, config *ServerConfig) (_ ServerTransport, err
shutdownChan: make(chan struct{}),
activeStreams: make(map[uint32]*Stream),
streamSendQuota: defaultWindowSize,
+ stats: config.StatsHandler,
}
- if stats.On() {
- t.ctx = stats.TagConn(t.ctx, &stats.ConnTagInfo{
+ if t.stats != nil {
+ t.ctx = t.stats.TagConn(t.ctx, &stats.ConnTagInfo{
RemoteAddr: t.remoteAddr,
LocalAddr: t.localAddr,
})
connBegin := &stats.ConnBegin{}
- stats.HandleConn(t.ctx, connBegin)
+ t.stats.HandleConn(t.ctx, connBegin)
}
go t.controller()
t.writableChan <- 0
@@ -250,8 +253,8 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
t.updateWindow(s, uint32(n))
}
s.ctx = traceCtx(s.ctx, s.method)
- if stats.On() {
- s.ctx = stats.TagRPC(s.ctx, &stats.RPCTagInfo{FullMethodName: s.method})
+ if t.stats != nil {
+ s.ctx = t.stats.TagRPC(s.ctx, &stats.RPCTagInfo{FullMethodName: s.method})
inHeader := &stats.InHeader{
FullMethod: s.method,
RemoteAddr: t.remoteAddr,
@@ -259,7 +262,7 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
Compression: s.recvCompress,
WireLength: int(frame.Header().Length),
}
- stats.HandleRPC(s.ctx, inHeader)
+ t.stats.HandleRPC(s.ctx, inHeader)
}
handle(s)
return
@@ -540,11 +543,11 @@ func (t *http2Server) WriteHeader(s *Stream, md metadata.MD) error {
if err := t.writeHeaders(s, t.hBuf, false); err != nil {
return err
}
- if stats.On() {
+ if t.stats != nil {
outHeader := &stats.OutHeader{
WireLength: bufLen,
}
- stats.HandleRPC(s.Context(), outHeader)
+ t.stats.HandleRPC(s.Context(), outHeader)
}
t.writableChan <- 0
return nil
@@ -603,11 +606,11 @@ func (t *http2Server) WriteStatus(s *Stream, statusCode codes.Code, statusDesc s
t.Close()
return err
}
- if stats.On() {
+ if t.stats != nil {
outTrailer := &stats.OutTrailer{
WireLength: bufLen,
}
- stats.HandleRPC(s.Context(), outTrailer)
+ t.stats.HandleRPC(s.Context(), outTrailer)
}
t.closeStream(s)
t.writableChan <- 0
@@ -789,9 +792,9 @@ func (t *http2Server) Close() (err error) {
for _, s := range streams {
s.cancel()
}
- if stats.On() {
+ if t.stats != nil {
connEnd := &stats.ConnEnd{}
- stats.HandleConn(t.ctx, connEnd)
+ t.stats.HandleConn(t.ctx, connEnd)
}
return
}
diff --git a/vendor/google.golang.org/grpc/transport/transport.go b/vendor/google.golang.org/grpc/transport/transport.go
index 4726bb2..d465991 100644
--- a/vendor/google.golang.org/grpc/transport/transport.go
+++ b/vendor/google.golang.org/grpc/transport/transport.go
@@ -48,6 +48,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
+ "google.golang.org/grpc/stats"
"google.golang.org/grpc/tap"
)
@@ -357,9 +358,10 @@ const (
// ServerConfig consists of all the configurations to establish a server transport.
type ServerConfig struct {
- MaxStreams uint32
- AuthInfo credentials.AuthInfo
- InTapHandle tap.ServerInHandle
+ MaxStreams uint32
+ AuthInfo credentials.AuthInfo
+ InTapHandle tap.ServerInHandle
+ StatsHandler stats.Handler
}
// NewServerTransport creates a ServerTransport with conn or non-nil error
@@ -380,6 +382,8 @@ type ConnectOptions struct {
PerRPCCredentials []credentials.PerRPCCredentials
// TransportCredentials stores the Authenticator required to setup a client connection.
TransportCredentials credentials.TransportCredentials
+ // StatsHandler stores the handler for stats.
+ StatsHandler stats.Handler
}
// TargetInfo contains the information of the target such as network address and metadata.