mirror of
				https://github.com/fnproject/fn.git
				synced 2022-10-28 21:29:17 +03:00 
			
		
		
		
	fn: upgrade to gRPC 1.17 (#1389)
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @@ -39,7 +39,7 @@ require ( | ||||
| 	golang.org/x/sys v0.0.0-20181019160139-8e24a49d80f8 | ||||
| 	golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 | ||||
| 	google.golang.org/api v0.0.0-20181019000435-7fb5a8353b60 // indirect | ||||
| 	google.golang.org/grpc v1.16.0 | ||||
| 	google.golang.org/grpc v1.17.0 | ||||
| 	gopkg.in/go-playground/validator.v8 v8.18.2 // indirect | ||||
| ) | ||||
|  | ||||
|   | ||||
							
								
								
									
										3
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								go.sum
									
									
									
									
									
								
							| @@ -212,6 +212,7 @@ golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4/go.mod h1:6SG95UA2DQfeDnf | ||||
| golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e h1:IzypfodbhbnViNUO/MEh0FzCUooG97cIGfdggUrUSyU= | ||||
| golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= | ||||
| golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | ||||
| golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | ||||
| golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||||
| golang.org/x/net v0.0.0-20180821023952-922f4815f713/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||||
| golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||||
| @@ -255,6 +256,8 @@ google.golang.org/grpc v1.15.0 h1:Az/KuahOM4NAidTEuJCv/RonAA7rYsTPkqXVjr+8OOw= | ||||
| google.golang.org/grpc v1.15.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= | ||||
| google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY= | ||||
| google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= | ||||
| google.golang.org/grpc v1.17.0 h1:TRJYBgMclJvGYn2rIMjj+h9KtMt5r1Ij7ODVRIZkwhk= | ||||
| google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= | ||||
| gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -14,8 +14,6 @@ matrix: | ||||
|   - go: 1.9.x | ||||
|   - go: 1.9.x | ||||
|     env: GAE=1 | ||||
|   - go: 1.8.x | ||||
|   - go: 1.6.x | ||||
|  | ||||
| go_import_path: google.golang.org/grpc | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -16,7 +16,7 @@ $ go get -u google.golang.org/grpc | ||||
| Prerequisites | ||||
| ------------- | ||||
|  | ||||
| This requires Go 1.6 or later. Go 1.7 will be required soon. | ||||
| gRPC-Go requires Go 1.9 or later. | ||||
|  | ||||
| Constraints | ||||
| ----------- | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/balancer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/balancer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,10 +19,10 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"net" | ||||
| 	"sync" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
|   | ||||
							
								
								
									
										5
									
								
								vendor/google.golang.org/grpc/balancer/balancer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/google.golang.org/grpc/balancer/balancer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,11 +21,11 @@ | ||||
| package balancer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"net" | ||||
| 	"strings" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/connectivity" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
| @@ -94,6 +94,9 @@ type NewSubConnOptions struct { | ||||
| 	// SubConn. If it's nil, the original creds from grpc DialOptions will be | ||||
| 	// used. | ||||
| 	CredsBundle credentials.Bundle | ||||
| 	// HealthCheckEnabled indicates whether health check service should be | ||||
| 	// enabled on this SubConn | ||||
| 	HealthCheckEnabled bool | ||||
| } | ||||
|  | ||||
| // ClientConn represents a gRPC ClientConn. | ||||
|   | ||||
							
								
								
									
										8
									
								
								vendor/google.golang.org/grpc/balancer/base/balancer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/google.golang.org/grpc/balancer/base/balancer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,7 +19,8 @@ | ||||
| package base | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/net/context" | ||||
| 	"context" | ||||
|  | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	"google.golang.org/grpc/connectivity" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| @@ -29,6 +30,7 @@ import ( | ||||
| type baseBuilder struct { | ||||
| 	name          string | ||||
| 	pickerBuilder PickerBuilder | ||||
| 	config        Config | ||||
| } | ||||
|  | ||||
| func (bb *baseBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) balancer.Balancer { | ||||
| @@ -43,6 +45,7 @@ func (bb *baseBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) | ||||
| 		// ErrNoSubConnAvailable, because when state of a SubConn changes, we | ||||
| 		// may call UpdateBalancerState with this picker. | ||||
| 		picker: NewErrPicker(balancer.ErrNoSubConnAvailable), | ||||
| 		config: bb.config, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -60,6 +63,7 @@ type baseBalancer struct { | ||||
| 	subConns map[resolver.Address]balancer.SubConn | ||||
| 	scStates map[balancer.SubConn]connectivity.State | ||||
| 	picker   balancer.Picker | ||||
| 	config   Config | ||||
| } | ||||
|  | ||||
| func (b *baseBalancer) HandleResolvedAddrs(addrs []resolver.Address, err error) { | ||||
| @@ -74,7 +78,7 @@ func (b *baseBalancer) HandleResolvedAddrs(addrs []resolver.Address, err error) | ||||
| 		addrsSet[a] = struct{}{} | ||||
| 		if _, ok := b.subConns[a]; !ok { | ||||
| 			// a is a new address (not existing in b.subConns). | ||||
| 			sc, err := b.cc.NewSubConn([]resolver.Address{a}, balancer.NewSubConnOptions{}) | ||||
| 			sc, err := b.cc.NewSubConn([]resolver.Address{a}, balancer.NewSubConnOptions{HealthCheckEnabled: b.config.HealthCheck}) | ||||
| 			if err != nil { | ||||
| 				grpclog.Warningf("base.baseBalancer: failed to create new SubConn: %v", err) | ||||
| 				continue | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/google.golang.org/grpc/balancer/base/base.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/google.golang.org/grpc/balancer/base/base.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -45,8 +45,20 @@ type PickerBuilder interface { | ||||
| // NewBalancerBuilder returns a balancer builder. The balancers | ||||
| // built by this builder will use the picker builder to build pickers. | ||||
| func NewBalancerBuilder(name string, pb PickerBuilder) balancer.Builder { | ||||
| 	return NewBalancerBuilderWithConfig(name, pb, Config{}) | ||||
| } | ||||
|  | ||||
| // Config contains the config info about the base balancer builder. | ||||
| type Config struct { | ||||
| 	// HealthCheck indicates whether health checking should be enabled for this specific balancer. | ||||
| 	HealthCheck bool | ||||
| } | ||||
|  | ||||
| // NewBalancerBuilderWithConfig returns a base balancer builder configured by the provided config. | ||||
| func NewBalancerBuilderWithConfig(name string, pb PickerBuilder, config Config) balancer.Builder { | ||||
| 	return &baseBuilder{ | ||||
| 		name:          name, | ||||
| 		pickerBuilder: pb, | ||||
| 		config:        config, | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -22,9 +22,9 @@ | ||||
| package roundrobin | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"sync" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	"google.golang.org/grpc/balancer/base" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| @@ -36,7 +36,7 @@ const Name = "round_robin" | ||||
|  | ||||
| // newBuilder creates a new roundrobin balancer builder. | ||||
| func newBuilder() balancer.Builder { | ||||
| 	return base.NewBalancerBuilder(Name, &rrPickerBuilder{}) | ||||
| 	return base.NewBalancerBuilderWithConfig(Name, &rrPickerBuilder{}, base.Config{HealthCheck: true}) | ||||
| } | ||||
|  | ||||
| func init() { | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/google.golang.org/grpc/balancer_conn_wrappers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/google.golang.org/grpc/balancer_conn_wrappers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -229,8 +229,13 @@ func (ccb *ccBalancerWrapper) UpdateBalancerState(s connectivity.State, p balanc | ||||
| 	if ccb.subConns == nil { | ||||
| 		return | ||||
| 	} | ||||
| 	ccb.cc.csMgr.updateState(s) | ||||
| 	// Update picker before updating state.  Even though the ordering here does | ||||
| 	// not matter, it can lead to multiple calls of Pick in the common start-up | ||||
| 	// case where we wait for ready and then perform an RPC.  If the picker is | ||||
| 	// updated later, we could call the "connecting" picker when the state is | ||||
| 	// updated, and then call the "ready" picker after the picker gets updated. | ||||
| 	ccb.cc.blockingpicker.updatePicker(p) | ||||
| 	ccb.cc.csMgr.updateState(s) | ||||
| } | ||||
|  | ||||
| func (ccb *ccBalancerWrapper) ResolveNow(o resolver.ResolveNowOption) { | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/balancer_v1_wrapper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/balancer_v1_wrapper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,10 +19,10 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/connectivity" | ||||
|   | ||||
							
								
								
									
										900
									
								
								vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										900
									
								
								vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,900 @@ | ||||
| // Code generated by protoc-gen-go. DO NOT EDIT. | ||||
| // source: grpc/binarylog/grpc_binarylog_v1/binarylog.proto | ||||
|  | ||||
| package grpc_binarylog_v1 // import "google.golang.org/grpc/binarylog/grpc_binarylog_v1" | ||||
|  | ||||
| import proto "github.com/golang/protobuf/proto" | ||||
| import fmt "fmt" | ||||
| import math "math" | ||||
| import duration "github.com/golang/protobuf/ptypes/duration" | ||||
| import timestamp "github.com/golang/protobuf/ptypes/timestamp" | ||||
|  | ||||
| // Reference imports to suppress errors if they are not otherwise used. | ||||
| var _ = proto.Marshal | ||||
| var _ = fmt.Errorf | ||||
| var _ = math.Inf | ||||
|  | ||||
| // This is a compile-time assertion to ensure that this generated file | ||||
| // is compatible with the proto package it is being compiled against. | ||||
| // A compilation error at this line likely means your copy of the | ||||
| // proto package needs to be updated. | ||||
| const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package | ||||
|  | ||||
| // Enumerates the type of event | ||||
| // Note the terminology is different from the RPC semantics | ||||
| // definition, but the same meaning is expressed here. | ||||
| type GrpcLogEntry_EventType int32 | ||||
|  | ||||
| const ( | ||||
| 	GrpcLogEntry_EVENT_TYPE_UNKNOWN GrpcLogEntry_EventType = 0 | ||||
| 	// Header sent from client to server | ||||
| 	GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER GrpcLogEntry_EventType = 1 | ||||
| 	// Header sent from server to client | ||||
| 	GrpcLogEntry_EVENT_TYPE_SERVER_HEADER GrpcLogEntry_EventType = 2 | ||||
| 	// Message sent from client to server | ||||
| 	GrpcLogEntry_EVENT_TYPE_CLIENT_MESSAGE GrpcLogEntry_EventType = 3 | ||||
| 	// Message sent from server to client | ||||
| 	GrpcLogEntry_EVENT_TYPE_SERVER_MESSAGE GrpcLogEntry_EventType = 4 | ||||
| 	// A signal that client is done sending | ||||
| 	GrpcLogEntry_EVENT_TYPE_CLIENT_HALF_CLOSE GrpcLogEntry_EventType = 5 | ||||
| 	// Trailer indicates the end of the RPC. | ||||
| 	// On client side, this event means a trailer was either received | ||||
| 	// from the network or the gRPC library locally generated a status | ||||
| 	// to inform the application about a failure. | ||||
| 	// On server side, this event means the server application requested | ||||
| 	// to send a trailer. Note: EVENT_TYPE_CANCEL may still arrive after | ||||
| 	// this due to races on server side. | ||||
| 	GrpcLogEntry_EVENT_TYPE_SERVER_TRAILER GrpcLogEntry_EventType = 6 | ||||
| 	// A signal that the RPC is cancelled. On client side, this | ||||
| 	// indicates the client application requests a cancellation. | ||||
| 	// On server side, this indicates that cancellation was detected. | ||||
| 	// Note: This marks the end of the RPC. Events may arrive after | ||||
| 	// this due to races. For example, on client side a trailer | ||||
| 	// may arrive even though the application requested to cancel the RPC. | ||||
| 	GrpcLogEntry_EVENT_TYPE_CANCEL GrpcLogEntry_EventType = 7 | ||||
| ) | ||||
|  | ||||
| var GrpcLogEntry_EventType_name = map[int32]string{ | ||||
| 	0: "EVENT_TYPE_UNKNOWN", | ||||
| 	1: "EVENT_TYPE_CLIENT_HEADER", | ||||
| 	2: "EVENT_TYPE_SERVER_HEADER", | ||||
| 	3: "EVENT_TYPE_CLIENT_MESSAGE", | ||||
| 	4: "EVENT_TYPE_SERVER_MESSAGE", | ||||
| 	5: "EVENT_TYPE_CLIENT_HALF_CLOSE", | ||||
| 	6: "EVENT_TYPE_SERVER_TRAILER", | ||||
| 	7: "EVENT_TYPE_CANCEL", | ||||
| } | ||||
| var GrpcLogEntry_EventType_value = map[string]int32{ | ||||
| 	"EVENT_TYPE_UNKNOWN":           0, | ||||
| 	"EVENT_TYPE_CLIENT_HEADER":     1, | ||||
| 	"EVENT_TYPE_SERVER_HEADER":     2, | ||||
| 	"EVENT_TYPE_CLIENT_MESSAGE":    3, | ||||
| 	"EVENT_TYPE_SERVER_MESSAGE":    4, | ||||
| 	"EVENT_TYPE_CLIENT_HALF_CLOSE": 5, | ||||
| 	"EVENT_TYPE_SERVER_TRAILER":    6, | ||||
| 	"EVENT_TYPE_CANCEL":            7, | ||||
| } | ||||
|  | ||||
| func (x GrpcLogEntry_EventType) String() string { | ||||
| 	return proto.EnumName(GrpcLogEntry_EventType_name, int32(x)) | ||||
| } | ||||
| func (GrpcLogEntry_EventType) EnumDescriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{0, 0} | ||||
| } | ||||
|  | ||||
| // Enumerates the entity that generates the log entry | ||||
| type GrpcLogEntry_Logger int32 | ||||
|  | ||||
| const ( | ||||
| 	GrpcLogEntry_LOGGER_UNKNOWN GrpcLogEntry_Logger = 0 | ||||
| 	GrpcLogEntry_LOGGER_CLIENT  GrpcLogEntry_Logger = 1 | ||||
| 	GrpcLogEntry_LOGGER_SERVER  GrpcLogEntry_Logger = 2 | ||||
| ) | ||||
|  | ||||
| var GrpcLogEntry_Logger_name = map[int32]string{ | ||||
| 	0: "LOGGER_UNKNOWN", | ||||
| 	1: "LOGGER_CLIENT", | ||||
| 	2: "LOGGER_SERVER", | ||||
| } | ||||
| var GrpcLogEntry_Logger_value = map[string]int32{ | ||||
| 	"LOGGER_UNKNOWN": 0, | ||||
| 	"LOGGER_CLIENT":  1, | ||||
| 	"LOGGER_SERVER":  2, | ||||
| } | ||||
|  | ||||
| func (x GrpcLogEntry_Logger) String() string { | ||||
| 	return proto.EnumName(GrpcLogEntry_Logger_name, int32(x)) | ||||
| } | ||||
| func (GrpcLogEntry_Logger) EnumDescriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{0, 1} | ||||
| } | ||||
|  | ||||
| type Address_Type int32 | ||||
|  | ||||
| const ( | ||||
| 	Address_TYPE_UNKNOWN Address_Type = 0 | ||||
| 	// address is in 1.2.3.4 form | ||||
| 	Address_TYPE_IPV4 Address_Type = 1 | ||||
| 	// address is in IPv6 canonical form (RFC5952 section 4) | ||||
| 	// The scope is NOT included in the address string. | ||||
| 	Address_TYPE_IPV6 Address_Type = 2 | ||||
| 	// address is UDS string | ||||
| 	Address_TYPE_UNIX Address_Type = 3 | ||||
| ) | ||||
|  | ||||
| var Address_Type_name = map[int32]string{ | ||||
| 	0: "TYPE_UNKNOWN", | ||||
| 	1: "TYPE_IPV4", | ||||
| 	2: "TYPE_IPV6", | ||||
| 	3: "TYPE_UNIX", | ||||
| } | ||||
| var Address_Type_value = map[string]int32{ | ||||
| 	"TYPE_UNKNOWN": 0, | ||||
| 	"TYPE_IPV4":    1, | ||||
| 	"TYPE_IPV6":    2, | ||||
| 	"TYPE_UNIX":    3, | ||||
| } | ||||
|  | ||||
| func (x Address_Type) String() string { | ||||
| 	return proto.EnumName(Address_Type_name, int32(x)) | ||||
| } | ||||
| func (Address_Type) EnumDescriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{7, 0} | ||||
| } | ||||
|  | ||||
| // Log entry we store in binary logs | ||||
| type GrpcLogEntry struct { | ||||
| 	// The timestamp of the binary log message | ||||
| 	Timestamp *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` | ||||
| 	// Uniquely identifies a call. The value must not be 0 in order to disambiguate | ||||
| 	// from an unset value. | ||||
| 	// Each call may have several log entries, they will all have the same call_id. | ||||
| 	// Nothing is guaranteed about their value other than they are unique across | ||||
| 	// different RPCs in the same gRPC process. | ||||
| 	CallId uint64 `protobuf:"varint,2,opt,name=call_id,json=callId,proto3" json:"call_id,omitempty"` | ||||
| 	// The entry sequence id for this call. The first GrpcLogEntry has a | ||||
| 	// value of 1, to disambiguate from an unset value. The purpose of | ||||
| 	// this field is to detect missing entries in environments where | ||||
| 	// durability or ordering is not guaranteed. | ||||
| 	SequenceIdWithinCall uint64                 `protobuf:"varint,3,opt,name=sequence_id_within_call,json=sequenceIdWithinCall,proto3" json:"sequence_id_within_call,omitempty"` | ||||
| 	Type                 GrpcLogEntry_EventType `protobuf:"varint,4,opt,name=type,proto3,enum=grpc.binarylog.v1.GrpcLogEntry_EventType" json:"type,omitempty"` | ||||
| 	Logger               GrpcLogEntry_Logger    `protobuf:"varint,5,opt,name=logger,proto3,enum=grpc.binarylog.v1.GrpcLogEntry_Logger" json:"logger,omitempty"` | ||||
| 	// The logger uses one of the following fields to record the payload, | ||||
| 	// according to the type of the log entry. | ||||
| 	// | ||||
| 	// Types that are valid to be assigned to Payload: | ||||
| 	//	*GrpcLogEntry_ClientHeader | ||||
| 	//	*GrpcLogEntry_ServerHeader | ||||
| 	//	*GrpcLogEntry_Message | ||||
| 	//	*GrpcLogEntry_Trailer | ||||
| 	Payload isGrpcLogEntry_Payload `protobuf_oneof:"payload"` | ||||
| 	// true if payload does not represent the full message or metadata. | ||||
| 	PayloadTruncated bool `protobuf:"varint,10,opt,name=payload_truncated,json=payloadTruncated,proto3" json:"payload_truncated,omitempty"` | ||||
| 	// Peer address information, will only be recorded on the first | ||||
| 	// incoming event. On client side, peer is logged on | ||||
| 	// EVENT_TYPE_SERVER_HEADER normally or EVENT_TYPE_SERVER_TRAILER in | ||||
| 	// the case of trailers-only. On server side, peer is always | ||||
| 	// logged on EVENT_TYPE_CLIENT_HEADER. | ||||
| 	Peer                 *Address `protobuf:"bytes,11,opt,name=peer,proto3" json:"peer,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) Reset()         { *m = GrpcLogEntry{} } | ||||
| func (m *GrpcLogEntry) String() string { return proto.CompactTextString(m) } | ||||
| func (*GrpcLogEntry) ProtoMessage()    {} | ||||
| func (*GrpcLogEntry) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{0} | ||||
| } | ||||
| func (m *GrpcLogEntry) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_GrpcLogEntry.Unmarshal(m, b) | ||||
| } | ||||
| func (m *GrpcLogEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_GrpcLogEntry.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (dst *GrpcLogEntry) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_GrpcLogEntry.Merge(dst, src) | ||||
| } | ||||
| func (m *GrpcLogEntry) XXX_Size() int { | ||||
| 	return xxx_messageInfo_GrpcLogEntry.Size(m) | ||||
| } | ||||
| func (m *GrpcLogEntry) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_GrpcLogEntry.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_GrpcLogEntry proto.InternalMessageInfo | ||||
|  | ||||
| func (m *GrpcLogEntry) GetTimestamp() *timestamp.Timestamp { | ||||
| 	if m != nil { | ||||
| 		return m.Timestamp | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetCallId() uint64 { | ||||
| 	if m != nil { | ||||
| 		return m.CallId | ||||
| 	} | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetSequenceIdWithinCall() uint64 { | ||||
| 	if m != nil { | ||||
| 		return m.SequenceIdWithinCall | ||||
| 	} | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetType() GrpcLogEntry_EventType { | ||||
| 	if m != nil { | ||||
| 		return m.Type | ||||
| 	} | ||||
| 	return GrpcLogEntry_EVENT_TYPE_UNKNOWN | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetLogger() GrpcLogEntry_Logger { | ||||
| 	if m != nil { | ||||
| 		return m.Logger | ||||
| 	} | ||||
| 	return GrpcLogEntry_LOGGER_UNKNOWN | ||||
| } | ||||
|  | ||||
| type isGrpcLogEntry_Payload interface { | ||||
| 	isGrpcLogEntry_Payload() | ||||
| } | ||||
|  | ||||
| type GrpcLogEntry_ClientHeader struct { | ||||
| 	ClientHeader *ClientHeader `protobuf:"bytes,6,opt,name=client_header,json=clientHeader,proto3,oneof"` | ||||
| } | ||||
|  | ||||
| type GrpcLogEntry_ServerHeader struct { | ||||
| 	ServerHeader *ServerHeader `protobuf:"bytes,7,opt,name=server_header,json=serverHeader,proto3,oneof"` | ||||
| } | ||||
|  | ||||
| type GrpcLogEntry_Message struct { | ||||
| 	Message *Message `protobuf:"bytes,8,opt,name=message,proto3,oneof"` | ||||
| } | ||||
|  | ||||
| type GrpcLogEntry_Trailer struct { | ||||
| 	Trailer *Trailer `protobuf:"bytes,9,opt,name=trailer,proto3,oneof"` | ||||
| } | ||||
|  | ||||
| func (*GrpcLogEntry_ClientHeader) isGrpcLogEntry_Payload() {} | ||||
|  | ||||
| func (*GrpcLogEntry_ServerHeader) isGrpcLogEntry_Payload() {} | ||||
|  | ||||
| func (*GrpcLogEntry_Message) isGrpcLogEntry_Payload() {} | ||||
|  | ||||
| func (*GrpcLogEntry_Trailer) isGrpcLogEntry_Payload() {} | ||||
|  | ||||
| func (m *GrpcLogEntry) GetPayload() isGrpcLogEntry_Payload { | ||||
| 	if m != nil { | ||||
| 		return m.Payload | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetClientHeader() *ClientHeader { | ||||
| 	if x, ok := m.GetPayload().(*GrpcLogEntry_ClientHeader); ok { | ||||
| 		return x.ClientHeader | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetServerHeader() *ServerHeader { | ||||
| 	if x, ok := m.GetPayload().(*GrpcLogEntry_ServerHeader); ok { | ||||
| 		return x.ServerHeader | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetMessage() *Message { | ||||
| 	if x, ok := m.GetPayload().(*GrpcLogEntry_Message); ok { | ||||
| 		return x.Message | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetTrailer() *Trailer { | ||||
| 	if x, ok := m.GetPayload().(*GrpcLogEntry_Trailer); ok { | ||||
| 		return x.Trailer | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetPayloadTruncated() bool { | ||||
| 	if m != nil { | ||||
| 		return m.PayloadTruncated | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func (m *GrpcLogEntry) GetPeer() *Address { | ||||
| 	if m != nil { | ||||
| 		return m.Peer | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // XXX_OneofFuncs is for the internal use of the proto package. | ||||
| func (*GrpcLogEntry) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { | ||||
| 	return _GrpcLogEntry_OneofMarshaler, _GrpcLogEntry_OneofUnmarshaler, _GrpcLogEntry_OneofSizer, []interface{}{ | ||||
| 		(*GrpcLogEntry_ClientHeader)(nil), | ||||
| 		(*GrpcLogEntry_ServerHeader)(nil), | ||||
| 		(*GrpcLogEntry_Message)(nil), | ||||
| 		(*GrpcLogEntry_Trailer)(nil), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func _GrpcLogEntry_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { | ||||
| 	m := msg.(*GrpcLogEntry) | ||||
| 	// payload | ||||
| 	switch x := m.Payload.(type) { | ||||
| 	case *GrpcLogEntry_ClientHeader: | ||||
| 		b.EncodeVarint(6<<3 | proto.WireBytes) | ||||
| 		if err := b.EncodeMessage(x.ClientHeader); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	case *GrpcLogEntry_ServerHeader: | ||||
| 		b.EncodeVarint(7<<3 | proto.WireBytes) | ||||
| 		if err := b.EncodeMessage(x.ServerHeader); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	case *GrpcLogEntry_Message: | ||||
| 		b.EncodeVarint(8<<3 | proto.WireBytes) | ||||
| 		if err := b.EncodeMessage(x.Message); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	case *GrpcLogEntry_Trailer: | ||||
| 		b.EncodeVarint(9<<3 | proto.WireBytes) | ||||
| 		if err := b.EncodeMessage(x.Trailer); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	case nil: | ||||
| 	default: | ||||
| 		return fmt.Errorf("GrpcLogEntry.Payload has unexpected type %T", x) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func _GrpcLogEntry_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { | ||||
| 	m := msg.(*GrpcLogEntry) | ||||
| 	switch tag { | ||||
| 	case 6: // payload.client_header | ||||
| 		if wire != proto.WireBytes { | ||||
| 			return true, proto.ErrInternalBadWireType | ||||
| 		} | ||||
| 		msg := new(ClientHeader) | ||||
| 		err := b.DecodeMessage(msg) | ||||
| 		m.Payload = &GrpcLogEntry_ClientHeader{msg} | ||||
| 		return true, err | ||||
| 	case 7: // payload.server_header | ||||
| 		if wire != proto.WireBytes { | ||||
| 			return true, proto.ErrInternalBadWireType | ||||
| 		} | ||||
| 		msg := new(ServerHeader) | ||||
| 		err := b.DecodeMessage(msg) | ||||
| 		m.Payload = &GrpcLogEntry_ServerHeader{msg} | ||||
| 		return true, err | ||||
| 	case 8: // payload.message | ||||
| 		if wire != proto.WireBytes { | ||||
| 			return true, proto.ErrInternalBadWireType | ||||
| 		} | ||||
| 		msg := new(Message) | ||||
| 		err := b.DecodeMessage(msg) | ||||
| 		m.Payload = &GrpcLogEntry_Message{msg} | ||||
| 		return true, err | ||||
| 	case 9: // payload.trailer | ||||
| 		if wire != proto.WireBytes { | ||||
| 			return true, proto.ErrInternalBadWireType | ||||
| 		} | ||||
| 		msg := new(Trailer) | ||||
| 		err := b.DecodeMessage(msg) | ||||
| 		m.Payload = &GrpcLogEntry_Trailer{msg} | ||||
| 		return true, err | ||||
| 	default: | ||||
| 		return false, nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func _GrpcLogEntry_OneofSizer(msg proto.Message) (n int) { | ||||
| 	m := msg.(*GrpcLogEntry) | ||||
| 	// payload | ||||
| 	switch x := m.Payload.(type) { | ||||
| 	case *GrpcLogEntry_ClientHeader: | ||||
| 		s := proto.Size(x.ClientHeader) | ||||
| 		n += 1 // tag and wire | ||||
| 		n += proto.SizeVarint(uint64(s)) | ||||
| 		n += s | ||||
| 	case *GrpcLogEntry_ServerHeader: | ||||
| 		s := proto.Size(x.ServerHeader) | ||||
| 		n += 1 // tag and wire | ||||
| 		n += proto.SizeVarint(uint64(s)) | ||||
| 		n += s | ||||
| 	case *GrpcLogEntry_Message: | ||||
| 		s := proto.Size(x.Message) | ||||
| 		n += 1 // tag and wire | ||||
| 		n += proto.SizeVarint(uint64(s)) | ||||
| 		n += s | ||||
| 	case *GrpcLogEntry_Trailer: | ||||
| 		s := proto.Size(x.Trailer) | ||||
| 		n += 1 // tag and wire | ||||
| 		n += proto.SizeVarint(uint64(s)) | ||||
| 		n += s | ||||
| 	case nil: | ||||
| 	default: | ||||
| 		panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| type ClientHeader struct { | ||||
| 	// This contains only the metadata from the application. | ||||
| 	Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` | ||||
| 	// The name of the RPC method, which looks something like: | ||||
| 	// /<service>/<method> | ||||
| 	// Note the leading "/" character. | ||||
| 	MethodName string `protobuf:"bytes,2,opt,name=method_name,json=methodName,proto3" json:"method_name,omitempty"` | ||||
| 	// A single process may be used to run multiple virtual | ||||
| 	// servers with different identities. | ||||
| 	// The authority is the name of such a server identitiy. | ||||
| 	// It is typically a portion of the URI in the form of | ||||
| 	// <host> or <host>:<port> . | ||||
| 	Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"` | ||||
| 	// the RPC timeout | ||||
| 	Timeout              *duration.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}           `json:"-"` | ||||
| 	XXX_unrecognized     []byte             `json:"-"` | ||||
| 	XXX_sizecache        int32              `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *ClientHeader) Reset()         { *m = ClientHeader{} } | ||||
| func (m *ClientHeader) String() string { return proto.CompactTextString(m) } | ||||
| func (*ClientHeader) ProtoMessage()    {} | ||||
| func (*ClientHeader) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{1} | ||||
| } | ||||
| func (m *ClientHeader) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_ClientHeader.Unmarshal(m, b) | ||||
| } | ||||
| func (m *ClientHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_ClientHeader.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (dst *ClientHeader) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_ClientHeader.Merge(dst, src) | ||||
| } | ||||
| func (m *ClientHeader) XXX_Size() int { | ||||
| 	return xxx_messageInfo_ClientHeader.Size(m) | ||||
| } | ||||
| func (m *ClientHeader) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_ClientHeader.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_ClientHeader proto.InternalMessageInfo | ||||
|  | ||||
| func (m *ClientHeader) GetMetadata() *Metadata { | ||||
| 	if m != nil { | ||||
| 		return m.Metadata | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *ClientHeader) GetMethodName() string { | ||||
| 	if m != nil { | ||||
| 		return m.MethodName | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func (m *ClientHeader) GetAuthority() string { | ||||
| 	if m != nil { | ||||
| 		return m.Authority | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func (m *ClientHeader) GetTimeout() *duration.Duration { | ||||
| 	if m != nil { | ||||
| 		return m.Timeout | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type ServerHeader struct { | ||||
| 	// This contains only the metadata from the application. | ||||
| 	Metadata             *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}  `json:"-"` | ||||
| 	XXX_unrecognized     []byte    `json:"-"` | ||||
| 	XXX_sizecache        int32     `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *ServerHeader) Reset()         { *m = ServerHeader{} } | ||||
| func (m *ServerHeader) String() string { return proto.CompactTextString(m) } | ||||
| func (*ServerHeader) ProtoMessage()    {} | ||||
| func (*ServerHeader) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{2} | ||||
| } | ||||
| func (m *ServerHeader) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_ServerHeader.Unmarshal(m, b) | ||||
| } | ||||
| func (m *ServerHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_ServerHeader.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (dst *ServerHeader) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_ServerHeader.Merge(dst, src) | ||||
| } | ||||
| func (m *ServerHeader) XXX_Size() int { | ||||
| 	return xxx_messageInfo_ServerHeader.Size(m) | ||||
| } | ||||
| func (m *ServerHeader) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_ServerHeader.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_ServerHeader proto.InternalMessageInfo | ||||
|  | ||||
| func (m *ServerHeader) GetMetadata() *Metadata { | ||||
| 	if m != nil { | ||||
| 		return m.Metadata | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type Trailer struct { | ||||
| 	// This contains only the metadata from the application. | ||||
| 	Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` | ||||
| 	// The gRPC status code. | ||||
| 	StatusCode uint32 `protobuf:"varint,2,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` | ||||
| 	// An original status message before any transport specific | ||||
| 	// encoding. | ||||
| 	StatusMessage string `protobuf:"bytes,3,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` | ||||
| 	// The value of the 'grpc-status-details-bin' metadata key. If | ||||
| 	// present, this is always an encoded 'google.rpc.Status' message. | ||||
| 	StatusDetails        []byte   `protobuf:"bytes,4,opt,name=status_details,json=statusDetails,proto3" json:"status_details,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *Trailer) Reset()         { *m = Trailer{} } | ||||
| func (m *Trailer) String() string { return proto.CompactTextString(m) } | ||||
| func (*Trailer) ProtoMessage()    {} | ||||
| func (*Trailer) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{3} | ||||
| } | ||||
| func (m *Trailer) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_Trailer.Unmarshal(m, b) | ||||
| } | ||||
| func (m *Trailer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_Trailer.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (dst *Trailer) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_Trailer.Merge(dst, src) | ||||
| } | ||||
| func (m *Trailer) XXX_Size() int { | ||||
| 	return xxx_messageInfo_Trailer.Size(m) | ||||
| } | ||||
| func (m *Trailer) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_Trailer.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_Trailer proto.InternalMessageInfo | ||||
|  | ||||
| func (m *Trailer) GetMetadata() *Metadata { | ||||
| 	if m != nil { | ||||
| 		return m.Metadata | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *Trailer) GetStatusCode() uint32 { | ||||
| 	if m != nil { | ||||
| 		return m.StatusCode | ||||
| 	} | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| func (m *Trailer) GetStatusMessage() string { | ||||
| 	if m != nil { | ||||
| 		return m.StatusMessage | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func (m *Trailer) GetStatusDetails() []byte { | ||||
| 	if m != nil { | ||||
| 		return m.StatusDetails | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Message payload, used by CLIENT_MESSAGE and SERVER_MESSAGE | ||||
| type Message struct { | ||||
| 	// Length of the message. It may not be the same as the length of the | ||||
| 	// data field, as the logging payload can be truncated or omitted. | ||||
| 	Length uint32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` | ||||
| 	// May be truncated or omitted. | ||||
| 	Data                 []byte   `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *Message) Reset()         { *m = Message{} } | ||||
| func (m *Message) String() string { return proto.CompactTextString(m) } | ||||
| func (*Message) ProtoMessage()    {} | ||||
| func (*Message) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{4} | ||||
| } | ||||
| func (m *Message) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_Message.Unmarshal(m, b) | ||||
| } | ||||
| func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_Message.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (dst *Message) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_Message.Merge(dst, src) | ||||
| } | ||||
| func (m *Message) XXX_Size() int { | ||||
| 	return xxx_messageInfo_Message.Size(m) | ||||
| } | ||||
| func (m *Message) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_Message.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_Message proto.InternalMessageInfo | ||||
|  | ||||
| func (m *Message) GetLength() uint32 { | ||||
| 	if m != nil { | ||||
| 		return m.Length | ||||
| 	} | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| func (m *Message) GetData() []byte { | ||||
| 	if m != nil { | ||||
| 		return m.Data | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // A list of metadata pairs, used in the payload of client header, | ||||
| // server header, and server trailer. | ||||
| // Implementations may omit some entries to honor the header limits | ||||
| // of GRPC_BINARY_LOG_CONFIG. | ||||
| // | ||||
| // Header keys added by gRPC are omitted. To be more specific, | ||||
| // implementations will not log the following entries, and this is | ||||
| // not to be treated as a truncation: | ||||
| // - entries handled by grpc that are not user visible, such as those | ||||
| //   that begin with 'grpc-' (with exception of grpc-trace-bin) | ||||
| //   or keys like 'lb-token' | ||||
| // - transport specific entries, including but not limited to: | ||||
| //   ':path', ':authority', 'content-encoding', 'user-agent', 'te', etc | ||||
| // - entries added for call credentials | ||||
| // | ||||
| // Implementations must always log grpc-trace-bin if it is present. | ||||
| // Practically speaking it will only be visible on server side because | ||||
| // grpc-trace-bin is managed by low level client side mechanisms | ||||
| // inaccessible from the application level. On server side, the | ||||
| // header is just a normal metadata key. | ||||
| // The pair will not count towards the size limit. | ||||
| type Metadata struct { | ||||
| 	Entry                []*MetadataEntry `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}         `json:"-"` | ||||
| 	XXX_unrecognized     []byte           `json:"-"` | ||||
| 	XXX_sizecache        int32            `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *Metadata) Reset()         { *m = Metadata{} } | ||||
| func (m *Metadata) String() string { return proto.CompactTextString(m) } | ||||
| func (*Metadata) ProtoMessage()    {} | ||||
| func (*Metadata) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{5} | ||||
| } | ||||
| func (m *Metadata) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_Metadata.Unmarshal(m, b) | ||||
| } | ||||
| func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_Metadata.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (dst *Metadata) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_Metadata.Merge(dst, src) | ||||
| } | ||||
| func (m *Metadata) XXX_Size() int { | ||||
| 	return xxx_messageInfo_Metadata.Size(m) | ||||
| } | ||||
| func (m *Metadata) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_Metadata.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_Metadata proto.InternalMessageInfo | ||||
|  | ||||
| func (m *Metadata) GetEntry() []*MetadataEntry { | ||||
| 	if m != nil { | ||||
| 		return m.Entry | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // A metadata key value pair | ||||
| type MetadataEntry struct { | ||||
| 	Key                  string   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` | ||||
| 	Value                []byte   `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *MetadataEntry) Reset()         { *m = MetadataEntry{} } | ||||
| func (m *MetadataEntry) String() string { return proto.CompactTextString(m) } | ||||
| func (*MetadataEntry) ProtoMessage()    {} | ||||
| func (*MetadataEntry) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{6} | ||||
| } | ||||
| func (m *MetadataEntry) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_MetadataEntry.Unmarshal(m, b) | ||||
| } | ||||
| func (m *MetadataEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_MetadataEntry.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (dst *MetadataEntry) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_MetadataEntry.Merge(dst, src) | ||||
| } | ||||
| func (m *MetadataEntry) XXX_Size() int { | ||||
| 	return xxx_messageInfo_MetadataEntry.Size(m) | ||||
| } | ||||
| func (m *MetadataEntry) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_MetadataEntry.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_MetadataEntry proto.InternalMessageInfo | ||||
|  | ||||
| func (m *MetadataEntry) GetKey() string { | ||||
| 	if m != nil { | ||||
| 		return m.Key | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func (m *MetadataEntry) GetValue() []byte { | ||||
| 	if m != nil { | ||||
| 		return m.Value | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Address information | ||||
| type Address struct { | ||||
| 	Type    Address_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.binarylog.v1.Address_Type" json:"type,omitempty"` | ||||
| 	Address string       `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` | ||||
| 	// only for TYPE_IPV4 and TYPE_IPV6 | ||||
| 	IpPort               uint32   `protobuf:"varint,3,opt,name=ip_port,json=ipPort,proto3" json:"ip_port,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *Address) Reset()         { *m = Address{} } | ||||
| func (m *Address) String() string { return proto.CompactTextString(m) } | ||||
| func (*Address) ProtoMessage()    {} | ||||
| func (*Address) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_binarylog_264c8c9c551ce911, []int{7} | ||||
| } | ||||
| func (m *Address) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_Address.Unmarshal(m, b) | ||||
| } | ||||
| func (m *Address) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_Address.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (dst *Address) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_Address.Merge(dst, src) | ||||
| } | ||||
| func (m *Address) XXX_Size() int { | ||||
| 	return xxx_messageInfo_Address.Size(m) | ||||
| } | ||||
| func (m *Address) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_Address.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_Address proto.InternalMessageInfo | ||||
|  | ||||
| func (m *Address) GetType() Address_Type { | ||||
| 	if m != nil { | ||||
| 		return m.Type | ||||
| 	} | ||||
| 	return Address_TYPE_UNKNOWN | ||||
| } | ||||
|  | ||||
| func (m *Address) GetAddress() string { | ||||
| 	if m != nil { | ||||
| 		return m.Address | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func (m *Address) GetIpPort() uint32 { | ||||
| 	if m != nil { | ||||
| 		return m.IpPort | ||||
| 	} | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	proto.RegisterType((*GrpcLogEntry)(nil), "grpc.binarylog.v1.GrpcLogEntry") | ||||
| 	proto.RegisterType((*ClientHeader)(nil), "grpc.binarylog.v1.ClientHeader") | ||||
| 	proto.RegisterType((*ServerHeader)(nil), "grpc.binarylog.v1.ServerHeader") | ||||
| 	proto.RegisterType((*Trailer)(nil), "grpc.binarylog.v1.Trailer") | ||||
| 	proto.RegisterType((*Message)(nil), "grpc.binarylog.v1.Message") | ||||
| 	proto.RegisterType((*Metadata)(nil), "grpc.binarylog.v1.Metadata") | ||||
| 	proto.RegisterType((*MetadataEntry)(nil), "grpc.binarylog.v1.MetadataEntry") | ||||
| 	proto.RegisterType((*Address)(nil), "grpc.binarylog.v1.Address") | ||||
| 	proto.RegisterEnum("grpc.binarylog.v1.GrpcLogEntry_EventType", GrpcLogEntry_EventType_name, GrpcLogEntry_EventType_value) | ||||
| 	proto.RegisterEnum("grpc.binarylog.v1.GrpcLogEntry_Logger", GrpcLogEntry_Logger_name, GrpcLogEntry_Logger_value) | ||||
| 	proto.RegisterEnum("grpc.binarylog.v1.Address_Type", Address_Type_name, Address_Type_value) | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	proto.RegisterFile("grpc/binarylog/grpc_binarylog_v1/binarylog.proto", fileDescriptor_binarylog_264c8c9c551ce911) | ||||
| } | ||||
|  | ||||
| var fileDescriptor_binarylog_264c8c9c551ce911 = []byte{ | ||||
| 	// 900 bytes of a gzipped FileDescriptorProto | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x51, 0x6f, 0xe3, 0x44, | ||||
| 	0x10, 0x3e, 0x37, 0x69, 0xdc, 0x4c, 0x92, 0xca, 0x5d, 0x95, 0x3b, 0x5f, 0x29, 0x34, 0xb2, 0x04, | ||||
| 	0x0a, 0x42, 0x72, 0xb9, 0x94, 0xeb, 0xf1, 0x02, 0x52, 0x92, 0xfa, 0xd2, 0x88, 0x5c, 0x1a, 0x6d, | ||||
| 	0x72, 0x3d, 0x40, 0x48, 0xd6, 0x36, 0x5e, 0x1c, 0x0b, 0xc7, 0x6b, 0xd6, 0x9b, 0xa0, 0xfc, 0x2c, | ||||
| 	0xde, 0x90, 0xee, 0x77, 0xf1, 0x8e, 0xbc, 0x6b, 0x27, 0xa6, 0x69, 0x0f, 0x09, 0xde, 0x3c, 0xdf, | ||||
| 	0x7c, 0xf3, 0xcd, 0xee, 0x78, 0x66, 0x16, 0xbe, 0xf2, 0x79, 0x3c, 0x3b, 0xbf, 0x0b, 0x22, 0xc2, | ||||
| 	0xd7, 0x21, 0xf3, 0xcf, 0x53, 0xd3, 0xdd, 0x98, 0xee, 0xea, 0xc5, 0xd6, 0x67, 0xc7, 0x9c, 0x09, | ||||
| 	0x86, 0x8e, 0x52, 0x8a, 0xbd, 0x45, 0x57, 0x2f, 0x4e, 0x3e, 0xf5, 0x19, 0xf3, 0x43, 0x7a, 0x2e, | ||||
| 	0x09, 0x77, 0xcb, 0x5f, 0xce, 0xbd, 0x25, 0x27, 0x22, 0x60, 0x91, 0x0a, 0x39, 0x39, 0xbb, 0xef, | ||||
| 	0x17, 0xc1, 0x82, 0x26, 0x82, 0x2c, 0x62, 0x45, 0xb0, 0xde, 0xeb, 0x50, 0xef, 0xf3, 0x78, 0x36, | ||||
| 	0x64, 0xbe, 0x13, 0x09, 0xbe, 0x46, 0xdf, 0x40, 0x75, 0xc3, 0x31, 0xb5, 0xa6, 0xd6, 0xaa, 0xb5, | ||||
| 	0x4f, 0x6c, 0xa5, 0x62, 0xe7, 0x2a, 0xf6, 0x34, 0x67, 0xe0, 0x2d, 0x19, 0x3d, 0x03, 0x7d, 0x46, | ||||
| 	0xc2, 0xd0, 0x0d, 0x3c, 0x73, 0xaf, 0xa9, 0xb5, 0xca, 0xb8, 0x92, 0x9a, 0x03, 0x0f, 0xbd, 0x84, | ||||
| 	0x67, 0x09, 0xfd, 0x6d, 0x49, 0xa3, 0x19, 0x75, 0x03, 0xcf, 0xfd, 0x3d, 0x10, 0xf3, 0x20, 0x72, | ||||
| 	0x53, 0xa7, 0x59, 0x92, 0xc4, 0xe3, 0xdc, 0x3d, 0xf0, 0xde, 0x49, 0x67, 0x8f, 0x84, 0x21, 0xfa, | ||||
| 	0x16, 0xca, 0x62, 0x1d, 0x53, 0xb3, 0xdc, 0xd4, 0x5a, 0x87, 0xed, 0x2f, 0xec, 0x9d, 0xdb, 0xdb, | ||||
| 	0xc5, 0x83, 0xdb, 0xce, 0x8a, 0x46, 0x62, 0xba, 0x8e, 0x29, 0x96, 0x61, 0xe8, 0x3b, 0xa8, 0x84, | ||||
| 	0xcc, 0xf7, 0x29, 0x37, 0xf7, 0xa5, 0xc0, 0xe7, 0xff, 0x26, 0x30, 0x94, 0x6c, 0x9c, 0x45, 0xa1, | ||||
| 	0xd7, 0xd0, 0x98, 0x85, 0x01, 0x8d, 0x84, 0x3b, 0xa7, 0xc4, 0xa3, 0xdc, 0xac, 0xc8, 0x62, 0x9c, | ||||
| 	0x3d, 0x20, 0xd3, 0x93, 0xbc, 0x6b, 0x49, 0xbb, 0x7e, 0x82, 0xeb, 0xb3, 0x82, 0x9d, 0xea, 0x24, | ||||
| 	0x94, 0xaf, 0x28, 0xcf, 0x75, 0xf4, 0x47, 0x75, 0x26, 0x92, 0xb7, 0xd5, 0x49, 0x0a, 0x36, 0xba, | ||||
| 	0x04, 0x7d, 0x41, 0x93, 0x84, 0xf8, 0xd4, 0x3c, 0xc8, 0x7f, 0xcb, 0x8e, 0xc2, 0x1b, 0xc5, 0xb8, | ||||
| 	0x7e, 0x82, 0x73, 0x72, 0x1a, 0x27, 0x38, 0x09, 0x42, 0xca, 0xcd, 0xea, 0xa3, 0x71, 0x53, 0xc5, | ||||
| 	0x48, 0xe3, 0x32, 0x32, 0xfa, 0x12, 0x8e, 0x62, 0xb2, 0x0e, 0x19, 0xf1, 0x5c, 0xc1, 0x97, 0xd1, | ||||
| 	0x8c, 0x08, 0xea, 0x99, 0xd0, 0xd4, 0x5a, 0x07, 0xd8, 0xc8, 0x1c, 0xd3, 0x1c, 0x47, 0x36, 0x94, | ||||
| 	0x63, 0x4a, 0xb9, 0x59, 0x7b, 0x34, 0x43, 0xc7, 0xf3, 0x38, 0x4d, 0x12, 0x2c, 0x79, 0xd6, 0x5f, | ||||
| 	0x1a, 0x54, 0x37, 0x3f, 0x0c, 0x3d, 0x05, 0xe4, 0xdc, 0x3a, 0xa3, 0xa9, 0x3b, 0xfd, 0x71, 0xec, | ||||
| 	0xb8, 0x6f, 0x47, 0xdf, 0x8f, 0x6e, 0xde, 0x8d, 0x8c, 0x27, 0xe8, 0x14, 0xcc, 0x02, 0xde, 0x1b, | ||||
| 	0x0e, 0xd2, 0xef, 0x6b, 0xa7, 0x73, 0xe5, 0x60, 0x43, 0xbb, 0xe7, 0x9d, 0x38, 0xf8, 0xd6, 0xc1, | ||||
| 	0xb9, 0x77, 0x0f, 0x7d, 0x02, 0xcf, 0x77, 0x63, 0xdf, 0x38, 0x93, 0x49, 0xa7, 0xef, 0x18, 0xa5, | ||||
| 	0x7b, 0xee, 0x2c, 0x38, 0x77, 0x97, 0x51, 0x13, 0x4e, 0x1f, 0xc8, 0xdc, 0x19, 0xbe, 0x76, 0x7b, | ||||
| 	0xc3, 0x9b, 0x89, 0x63, 0xec, 0x3f, 0x2c, 0x30, 0xc5, 0x9d, 0xc1, 0xd0, 0xc1, 0x46, 0x05, 0x7d, | ||||
| 	0x04, 0x47, 0x45, 0x81, 0xce, 0xa8, 0xe7, 0x0c, 0x0d, 0xdd, 0xea, 0x42, 0x45, 0xb5, 0x19, 0x42, | ||||
| 	0x70, 0x38, 0xbc, 0xe9, 0xf7, 0x1d, 0x5c, 0xb8, 0xef, 0x11, 0x34, 0x32, 0x4c, 0x65, 0x34, 0xb4, | ||||
| 	0x02, 0xa4, 0x52, 0x18, 0x7b, 0xdd, 0x2a, 0xe8, 0x59, 0xfd, 0xad, 0xf7, 0x1a, 0xd4, 0x8b, 0xcd, | ||||
| 	0x87, 0x5e, 0xc1, 0xc1, 0x82, 0x0a, 0xe2, 0x11, 0x41, 0xb2, 0xe1, 0xfd, 0xf8, 0xc1, 0x2e, 0x51, | ||||
| 	0x14, 0xbc, 0x21, 0xa3, 0x33, 0xa8, 0x2d, 0xa8, 0x98, 0x33, 0xcf, 0x8d, 0xc8, 0x82, 0xca, 0x01, | ||||
| 	0xae, 0x62, 0x50, 0xd0, 0x88, 0x2c, 0x28, 0x3a, 0x85, 0x2a, 0x59, 0x8a, 0x39, 0xe3, 0x81, 0x58, | ||||
| 	0xcb, 0xb1, 0xad, 0xe2, 0x2d, 0x80, 0x2e, 0x40, 0x4f, 0x17, 0x01, 0x5b, 0x0a, 0x39, 0xae, 0xb5, | ||||
| 	0xf6, 0xf3, 0x9d, 0x9d, 0x71, 0x95, 0x6d, 0x26, 0x9c, 0x33, 0xad, 0x3e, 0xd4, 0x8b, 0x1d, 0xff, | ||||
| 	0x9f, 0x0f, 0x6f, 0xfd, 0xa1, 0x81, 0x9e, 0x75, 0xf0, 0xff, 0xaa, 0x40, 0x22, 0x88, 0x58, 0x26, | ||||
| 	0xee, 0x8c, 0x79, 0xaa, 0x02, 0x0d, 0x0c, 0x0a, 0xea, 0x31, 0x8f, 0xa2, 0xcf, 0xe0, 0x30, 0x23, | ||||
| 	0xe4, 0x73, 0xa8, 0xca, 0xd0, 0x50, 0x68, 0x36, 0x7a, 0x05, 0x9a, 0x47, 0x05, 0x09, 0xc2, 0x44, | ||||
| 	0x56, 0xa4, 0x9e, 0xd3, 0xae, 0x14, 0x68, 0xbd, 0x04, 0x3d, 0x8f, 0x78, 0x0a, 0x95, 0x90, 0x46, | ||||
| 	0xbe, 0x98, 0xcb, 0x03, 0x37, 0x70, 0x66, 0x21, 0x04, 0x65, 0x79, 0x8d, 0x3d, 0x19, 0x2f, 0xbf, | ||||
| 	0xad, 0x2e, 0x1c, 0xe4, 0x67, 0x47, 0x97, 0xb0, 0x4f, 0xd3, 0xcd, 0x65, 0x6a, 0xcd, 0x52, 0xab, | ||||
| 	0xd6, 0x6e, 0x7e, 0xe0, 0x9e, 0x72, 0xc3, 0x61, 0x45, 0xb7, 0x5e, 0x41, 0xe3, 0x1f, 0x38, 0x32, | ||||
| 	0xa0, 0xf4, 0x2b, 0x5d, 0xcb, 0xec, 0x55, 0x9c, 0x7e, 0xa2, 0x63, 0xd8, 0x5f, 0x91, 0x70, 0x49, | ||||
| 	0xb3, 0xdc, 0xca, 0xb0, 0xfe, 0xd4, 0x40, 0xcf, 0xe6, 0x18, 0x5d, 0x64, 0xdb, 0x59, 0x93, 0xcb, | ||||
| 	0xf5, 0xec, 0xf1, 0x89, 0xb7, 0x0b, 0x3b, 0xd9, 0x04, 0x9d, 0x28, 0x34, 0xeb, 0xb0, 0xdc, 0x4c, | ||||
| 	0x1f, 0x8f, 0x20, 0x76, 0x63, 0xc6, 0x85, 0xac, 0x6a, 0x03, 0x57, 0x82, 0x78, 0xcc, 0xb8, 0xb0, | ||||
| 	0x1c, 0x28, 0xcb, 0x1d, 0x61, 0x40, 0xfd, 0xde, 0x76, 0x68, 0x40, 0x55, 0x22, 0x83, 0xf1, 0xed, | ||||
| 	0xd7, 0x86, 0x56, 0x34, 0x2f, 0x8d, 0xbd, 0x8d, 0xf9, 0x76, 0x34, 0xf8, 0xc1, 0x28, 0x75, 0x7f, | ||||
| 	0x86, 0xe3, 0x80, 0xed, 0x1e, 0xb2, 0x7b, 0xd8, 0x95, 0xd6, 0x90, 0xf9, 0xe3, 0xb4, 0x51, 0xc7, | ||||
| 	0xda, 0x4f, 0xed, 0xac, 0x71, 0x7d, 0x16, 0x92, 0xc8, 0xb7, 0x19, 0x57, 0x4f, 0xf3, 0x87, 0x5e, | ||||
| 	0xea, 0xbb, 0x8a, 0xec, 0xf2, 0x8b, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xf6, 0x4b, 0x50, | ||||
| 	0xd4, 0x07, 0x00, 0x00, | ||||
| } | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/call.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/call.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,7 +19,7 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/net/context" | ||||
| 	"context" | ||||
| ) | ||||
|  | ||||
| // Invoke sends the RPC request on the wire and returns after response is | ||||
|   | ||||
							
								
								
									
										174
									
								
								vendor/google.golang.org/grpc/clientconn.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										174
									
								
								vendor/google.golang.org/grpc/clientconn.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,6 +19,7 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
| @@ -29,15 +30,17 @@ import ( | ||||
| 	"sync/atomic" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	_ "google.golang.org/grpc/balancer/roundrobin" // To register roundrobin. | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/connectivity" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| 	"google.golang.org/grpc/internal" | ||||
| 	"google.golang.org/grpc/internal/backoff" | ||||
| 	"google.golang.org/grpc/internal/channelz" | ||||
| 	"google.golang.org/grpc/internal/envconfig" | ||||
| 	"google.golang.org/grpc/internal/grpcsync" | ||||
| 	"google.golang.org/grpc/internal/transport" | ||||
| 	"google.golang.org/grpc/keepalive" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
| @@ -129,6 +132,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * | ||||
| 		dopts:             defaultDialOptions(), | ||||
| 		blockingpicker:    newPickerWrapper(), | ||||
| 		czData:            new(channelzData), | ||||
| 		firstResolveEvent: grpcsync.NewEvent(), | ||||
| 	} | ||||
| 	cc.retryThrottler.Store((*retryThrottler)(nil)) | ||||
| 	cc.ctx, cc.cancel = context.WithCancel(context.Background()) | ||||
| @@ -182,7 +186,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * | ||||
| 		cc.dopts.copts.Dialer = newProxyDialer( | ||||
| 			func(ctx context.Context, addr string) (net.Conn, error) { | ||||
| 				network, addr := parseDialTarget(addr) | ||||
| 				return dialContext(ctx, network, addr) | ||||
| 				return (&net.Dialer{}).DialContext(ctx, network, addr) | ||||
| 			}, | ||||
| 		) | ||||
| 	} | ||||
| @@ -285,19 +289,14 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * | ||||
| 	} | ||||
|  | ||||
| 	// Build the resolver. | ||||
| 	cc.resolverWrapper, err = newCCResolverWrapper(cc) | ||||
| 	rWrapper, err := newCCResolverWrapper(cc) | ||||
| 	if err != nil { | ||||
| 		return nil, fmt.Errorf("failed to build resolver: %v", err) | ||||
| 	} | ||||
| 	// Start the resolver wrapper goroutine after resolverWrapper is created. | ||||
| 	// | ||||
| 	// If the goroutine is started before resolverWrapper is ready, the | ||||
| 	// following may happen: The goroutine sends updates to cc. cc forwards | ||||
| 	// those to balancer. Balancer creates new addrConn. addrConn fails to | ||||
| 	// connect, and calls resolveNow(). resolveNow() tries to use the non-ready | ||||
| 	// resolverWrapper. | ||||
| 	cc.resolverWrapper.start() | ||||
|  | ||||
| 	cc.mu.Lock() | ||||
| 	cc.resolverWrapper = rWrapper | ||||
| 	cc.mu.Unlock() | ||||
| 	// A blocking dial blocks until the clientConn is ready. | ||||
| 	if cc.dopts.block { | ||||
| 		for { | ||||
| @@ -306,7 +305,9 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * | ||||
| 				break | ||||
| 			} else if cc.dopts.copts.FailOnNonTempDialError && s == connectivity.TransientFailure { | ||||
| 				if err = cc.blockingpicker.connectionError(); err != nil { | ||||
| 					terr, ok := err.(interface{ Temporary() bool }) | ||||
| 					terr, ok := err.(interface { | ||||
| 						Temporary() bool | ||||
| 					}) | ||||
| 					if ok && !terr.Temporary() { | ||||
| 						return nil, err | ||||
| 					} | ||||
| @@ -384,10 +385,10 @@ type ClientConn struct { | ||||
| 	csMgr        *connectivityStateManager | ||||
|  | ||||
| 	balancerBuildOpts balancer.BuildOptions | ||||
| 	resolverWrapper   *ccResolverWrapper | ||||
| 	blockingpicker    *pickerWrapper | ||||
|  | ||||
| 	mu              sync.RWMutex | ||||
| 	resolverWrapper *ccResolverWrapper | ||||
| 	sc              ServiceConfig | ||||
| 	scRaw           string | ||||
| 	conns           map[*addrConn]struct{} | ||||
| @@ -399,6 +400,8 @@ type ClientConn struct { | ||||
| 	balancerWrapper *ccBalancerWrapper | ||||
| 	retryThrottler  atomic.Value | ||||
|  | ||||
| 	firstResolveEvent *grpcsync.Event | ||||
|  | ||||
| 	channelzID int64 // channelz unique identification number | ||||
| 	czData     *channelzData | ||||
| } | ||||
| @@ -444,6 +447,25 @@ func (cc *ClientConn) scWatcher() { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // waitForResolvedAddrs blocks until the resolver has provided addresses or the | ||||
| // context expires.  Returns nil unless the context expires first; otherwise | ||||
| // returns a status error based on the context. | ||||
| func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) error { | ||||
| 	// This is on the RPC path, so we use a fast path to avoid the | ||||
| 	// more-expensive "select" below after the resolver has returned once. | ||||
| 	if cc.firstResolveEvent.HasFired() { | ||||
| 		return nil | ||||
| 	} | ||||
| 	select { | ||||
| 	case <-cc.firstResolveEvent.Done(): | ||||
| 		return nil | ||||
| 	case <-ctx.Done(): | ||||
| 		return status.FromContextError(ctx.Err()).Err() | ||||
| 	case <-cc.ctx.Done(): | ||||
| 		return ErrClientConnClosing | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (cc *ClientConn) handleResolvedAddrs(addrs []resolver.Address, err error) { | ||||
| 	cc.mu.Lock() | ||||
| 	defer cc.mu.Unlock() | ||||
| @@ -457,6 +479,7 @@ func (cc *ClientConn) handleResolvedAddrs(addrs []resolver.Address, err error) { | ||||
| 	} | ||||
|  | ||||
| 	cc.curAddresses = addrs | ||||
| 	cc.firstResolveEvent.Fire() | ||||
|  | ||||
| 	if cc.dopts.balancerBuilder == nil { | ||||
| 		// Only look at balancer types and switch balancer if balancer dial | ||||
| @@ -715,6 +738,12 @@ func (cc *ClientConn) GetMethodConfig(method string) MethodConfig { | ||||
| 	return m | ||||
| } | ||||
|  | ||||
| func (cc *ClientConn) healthCheckConfig() *healthCheckConfig { | ||||
| 	cc.mu.RLock() | ||||
| 	defer cc.mu.RUnlock() | ||||
| 	return cc.sc.healthCheckConfig | ||||
| } | ||||
|  | ||||
| func (cc *ClientConn) getTransport(ctx context.Context, failfast bool, method string) (transport.ClientTransport, func(balancer.DoneInfo), error) { | ||||
| 	hdr, _ := metadata.FromOutgoingContext(ctx) | ||||
| 	t, done, err := cc.blockingpicker.pick(ctx, failfast, balancer.PickOptions{ | ||||
| @@ -877,6 +906,10 @@ type addrConn struct { | ||||
| 	acbw   balancer.SubConn | ||||
| 	scopts balancer.NewSubConnOptions | ||||
|  | ||||
| 	// transport is set when there's a viable transport (note: ac state may not be READY as LB channel | ||||
| 	// health checking may require server to report healthy to set ac to READY), and is reset | ||||
| 	// to nil when the current transport should no longer be used to create a stream (e.g. after GoAway | ||||
| 	// is received, transport is closed, ac has been torn down). | ||||
| 	transport transport.ClientTransport // The current transport. | ||||
|  | ||||
| 	mu      sync.Mutex | ||||
| @@ -903,6 +936,8 @@ type addrConn struct { | ||||
| 	czData     *channelzData | ||||
|  | ||||
| 	successfulHandshake bool | ||||
|  | ||||
| 	healthCheckEnabled bool | ||||
| } | ||||
|  | ||||
| // Note: this requires a lock on ac.mu. | ||||
| @@ -956,6 +991,8 @@ func (ac *addrConn) resetTransport(resolveNow bool) { | ||||
| 			return | ||||
| 		} | ||||
|  | ||||
| 		// The transport that was used before is no longer viable. | ||||
| 		ac.transport = nil | ||||
| 		// If the connection is READY, a failure must have occurred. | ||||
| 		// Otherwise, we'll consider this is a transient failure when: | ||||
| 		//   We've exhausted all addresses | ||||
| @@ -1044,7 +1081,10 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
| 	var serverPrefaceReceived bool | ||||
| 	var clientPrefaceWrote bool | ||||
|  | ||||
| 	hcCtx, hcCancel := context.WithCancel(ac.ctx) | ||||
|  | ||||
| 	onGoAway := func(r transport.GoAwayReason) { | ||||
| 		hcCancel() | ||||
| 		ac.mu.Lock() | ||||
| 		ac.adjustParams(r) | ||||
| 		ac.mu.Unlock() | ||||
| @@ -1059,6 +1099,7 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
| 	prefaceTimer := time.NewTimer(connectDeadline.Sub(time.Now())) | ||||
|  | ||||
| 	onClose := func() { | ||||
| 		hcCancel() | ||||
| 		close(onCloseCalled) | ||||
| 		prefaceTimer.Stop() | ||||
|  | ||||
| @@ -1087,18 +1128,14 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
| 		serverPrefaceReceived = true | ||||
| 		if clientPrefaceWrote { | ||||
| 			ac.successfulHandshake = true | ||||
| 			ac.backoffDeadline = time.Time{} | ||||
| 			ac.connectDeadline = time.Time{} | ||||
| 			ac.addrIdx = 0 | ||||
| 			ac.backoffIdx = 0 | ||||
| 		} | ||||
| 		prefaceMu.Unlock() | ||||
|  | ||||
| 		ac.mu.Unlock() | ||||
| 	} | ||||
|  | ||||
| 	// Do not cancel in the success path because of this issue in Go1.6: https://github.com/golang/go/issues/15078. | ||||
| 	connectCtx, cancel := context.WithDeadline(ac.ctx, connectDeadline) | ||||
| 	defer cancel() | ||||
| 	if channelz.IsOn() { | ||||
| 		copts.ChannelzParentID = ac.channelzID | ||||
| 	} | ||||
| @@ -1108,12 +1145,12 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
| 	if err == nil { | ||||
| 		prefaceMu.Lock() | ||||
| 		clientPrefaceWrote = true | ||||
| 		if serverPrefaceReceived { | ||||
| 		if serverPrefaceReceived || ac.dopts.reqHandshake == envconfig.RequireHandshakeOff { | ||||
| 			ac.successfulHandshake = true | ||||
| 		} | ||||
| 		prefaceMu.Unlock() | ||||
|  | ||||
| 		if ac.dopts.waitForHandshake { | ||||
| 		if ac.dopts.reqHandshake == envconfig.RequireHandshakeOn { | ||||
| 			select { | ||||
| 			case <-prefaceTimer.C: | ||||
| 				// We didn't get the preface in time. | ||||
| @@ -1126,7 +1163,7 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
| 				close(allowedToReset) | ||||
| 				return nil | ||||
| 			} | ||||
| 		} else { | ||||
| 		} else if ac.dopts.reqHandshake == envconfig.RequireHandshakeHybrid { | ||||
| 			go func() { | ||||
| 				select { | ||||
| 				case <-prefaceTimer.C: | ||||
| @@ -1143,7 +1180,6 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
|  | ||||
| 	if err != nil { | ||||
| 		// newTr is either nil, or closed. | ||||
| 		cancel() | ||||
| 		ac.cc.blockingpicker.updateConnectionError(err) | ||||
| 		ac.mu.Lock() | ||||
| 		if ac.state == connectivity.Shutdown { | ||||
| @@ -1166,22 +1202,46 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	// Now there is a viable transport to be use, so set ac.transport to reflect the new viable transport. | ||||
| 	ac.mu.Lock() | ||||
| 	if ac.state == connectivity.Shutdown { | ||||
| 		ac.mu.Unlock() | ||||
| 		close(skipReset) | ||||
| 		newTr.Close() | ||||
| 		return nil | ||||
| 	} | ||||
| 	ac.transport = newTr | ||||
| 	ac.mu.Unlock() | ||||
|  | ||||
| 	healthCheckConfig := ac.cc.healthCheckConfig() | ||||
| 	// LB channel health checking is only enabled when all the four requirements below are met: | ||||
| 	// 1. it is not disabled by the user with the WithDisableHealthCheck DialOption, | ||||
| 	// 2. the internal.HealthCheckFunc is set by importing the grpc/healthcheck package, | ||||
| 	// 3. a service config with non-empty healthCheckConfig field is provided, | ||||
| 	// 4. the current load balancer allows it. | ||||
| 	if !ac.cc.dopts.disableHealthCheck && healthCheckConfig != nil && ac.scopts.HealthCheckEnabled { | ||||
| 		if internal.HealthCheckFunc != nil { | ||||
| 			go ac.startHealthCheck(hcCtx, newTr, addr, healthCheckConfig.ServiceName) | ||||
| 			close(allowedToReset) | ||||
| 			return nil | ||||
| 		} | ||||
| 		// TODO: add a link to the health check doc in the error message. | ||||
| 		grpclog.Error("the client side LB channel health check function has not been set.") | ||||
| 	} | ||||
|  | ||||
| 	// No LB channel health check case | ||||
| 	ac.mu.Lock() | ||||
|  | ||||
| 	if ac.state == connectivity.Shutdown { | ||||
| 		ac.mu.Unlock() | ||||
|  | ||||
| 		// We don't want to reset during this close because we prefer to kick out of this function and let the loop | ||||
| 		// in resetTransport take care of reconnecting. | ||||
| 		// unblock onGoAway/onClose callback. | ||||
| 		close(skipReset) | ||||
|  | ||||
| 		newTr.Close() | ||||
| 		return errConnClosing | ||||
| 	} | ||||
|  | ||||
| 	ac.updateConnectivityState(connectivity.Ready) | ||||
| 	ac.cc.handleSubConnStateChange(ac.acbw, ac.state) | ||||
| 	ac.transport = newTr | ||||
| 	ac.curAddr = addr | ||||
|  | ||||
| 	ac.mu.Unlock() | ||||
| @@ -1192,6 +1252,51 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (ac *addrConn) startHealthCheck(ctx context.Context, newTr transport.ClientTransport, addr resolver.Address, serviceName string) { | ||||
| 	// Set up the health check helper functions | ||||
| 	newStream := func() (interface{}, error) { | ||||
| 		return ac.newClientStream(ctx, &StreamDesc{ServerStreams: true}, "/grpc.health.v1.Health/Watch", newTr) | ||||
| 	} | ||||
| 	firstReady := true | ||||
| 	reportHealth := func(ok bool) { | ||||
| 		ac.mu.Lock() | ||||
| 		defer ac.mu.Unlock() | ||||
| 		if ac.transport != newTr { | ||||
| 			return | ||||
| 		} | ||||
| 		if ok { | ||||
| 			if firstReady { | ||||
| 				firstReady = false | ||||
| 				ac.curAddr = addr | ||||
| 			} | ||||
| 			if ac.state != connectivity.Ready { | ||||
| 				ac.updateConnectivityState(connectivity.Ready) | ||||
| 				ac.cc.handleSubConnStateChange(ac.acbw, ac.state) | ||||
| 			} | ||||
| 		} else { | ||||
| 			if ac.state != connectivity.TransientFailure { | ||||
| 				ac.updateConnectivityState(connectivity.TransientFailure) | ||||
| 				ac.cc.handleSubConnStateChange(ac.acbw, ac.state) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	err := internal.HealthCheckFunc(ctx, newStream, reportHealth, serviceName) | ||||
| 	if err != nil { | ||||
| 		if status.Code(err) == codes.Unimplemented { | ||||
| 			if channelz.IsOn() { | ||||
| 				channelz.AddTraceEvent(ac.channelzID, &channelz.TraceEventDesc{ | ||||
| 					Desc:     "Subchannel health check is unimplemented at server side, thus health check is disabled", | ||||
| 					Severity: channelz.CtError, | ||||
| 				}) | ||||
| 			} | ||||
| 			grpclog.Error("Subchannel health check is unimplemented at server side, thus health check is disabled") | ||||
| 		} else { | ||||
| 			grpclog.Errorf("HealthCheckFunc exits with unexpected error %v", err) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // nextAddr increments the addrIdx if there are more addresses to try. If | ||||
| // there are no more addrs to try it will re-resolve, set addrIdx to 0, and | ||||
| // increment the backoffIdx. | ||||
| @@ -1200,11 +1305,14 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts | ||||
| func (ac *addrConn) nextAddr() error { | ||||
| 	ac.mu.Lock() | ||||
|  | ||||
| 	// If a handshake has been observed, we expect the counters to have manually | ||||
| 	// been reset so we'll just return, since we want the next usage to start | ||||
| 	// at index 0. | ||||
| 	// If a handshake has been observed, we want the next usage to start at | ||||
| 	// index 0 immediately. | ||||
| 	if ac.successfulHandshake { | ||||
| 		ac.successfulHandshake = false | ||||
| 		ac.backoffDeadline = time.Time{} | ||||
| 		ac.connectDeadline = time.Time{} | ||||
| 		ac.addrIdx = 0 | ||||
| 		ac.backoffIdx = 0 | ||||
| 		ac.mu.Unlock() | ||||
| 		return nil | ||||
| 	} | ||||
| @@ -1279,6 +1387,8 @@ func (ac *addrConn) tearDown(err error) { | ||||
| 		ac.mu.Unlock() | ||||
| 		return | ||||
| 	} | ||||
| 	curTr := ac.transport | ||||
| 	ac.transport = nil | ||||
| 	// We have to set the state to Shutdown before anything else to prevent races | ||||
| 	// between setting the state and logic that waits on context cancelation / etc. | ||||
| 	ac.updateConnectivityState(connectivity.Shutdown) | ||||
| @@ -1286,14 +1396,14 @@ func (ac *addrConn) tearDown(err error) { | ||||
| 	ac.tearDownErr = err | ||||
| 	ac.cc.handleSubConnStateChange(ac.acbw, ac.state) | ||||
| 	ac.curAddr = resolver.Address{} | ||||
| 	if err == errConnDrain && ac.transport != nil { | ||||
| 	if err == errConnDrain && curTr != nil { | ||||
| 		// GracefulClose(...) may be executed multiple times when | ||||
| 		// i) receiving multiple GoAway frames from the server; or | ||||
| 		// ii) there are concurrent name resolver/Balancer triggered | ||||
| 		// address removal and GoAway. | ||||
| 		// We have to unlock and re-lock here because GracefulClose => Close => onClose, which requires locking ac.mu. | ||||
| 		ac.mu.Unlock() | ||||
| 		ac.transport.GracefulClose() | ||||
| 		curTr.GracefulClose() | ||||
| 		ac.mu.Lock() | ||||
| 	} | ||||
| 	if channelz.IsOn() { | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/google.golang.org/grpc/connectivity/connectivity.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/google.golang.org/grpc/connectivity/connectivity.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -22,7 +22,8 @@ | ||||
| package connectivity | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/net/context" | ||||
| 	"context" | ||||
|  | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| ) | ||||
|  | ||||
|   | ||||
							
								
								
									
										36
									
								
								vendor/google.golang.org/grpc/credentials/credentials.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								vendor/google.golang.org/grpc/credentials/credentials.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -23,6 +23,7 @@ | ||||
| package credentials // import "google.golang.org/grpc/credentials" | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"crypto/tls" | ||||
| 	"crypto/x509" | ||||
| 	"errors" | ||||
| @@ -32,7 +33,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/golang/protobuf/proto" | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/credentials/internal" | ||||
| ) | ||||
|  | ||||
| // alpnProtoStr are the specified application level protocols for gRPC. | ||||
| @@ -138,8 +139,8 @@ func (t TLSInfo) AuthType() string { | ||||
| 	return "tls" | ||||
| } | ||||
|  | ||||
| // GetChannelzSecurityValue returns security info requested by channelz. | ||||
| func (t TLSInfo) GetChannelzSecurityValue() ChannelzSecurityValue { | ||||
| // GetSecurityValue returns security info requested by channelz. | ||||
| func (t TLSInfo) GetSecurityValue() ChannelzSecurityValue { | ||||
| 	v := &TLSChannelzSecurityValue{ | ||||
| 		StandardName: cipherSuiteLookup[t.State.CipherSuite], | ||||
| 	} | ||||
| @@ -187,7 +188,7 @@ func (c *tlsCreds) ClientHandshake(ctx context.Context, authority string, rawCon | ||||
| 	case <-ctx.Done(): | ||||
| 		return nil, nil, ctx.Err() | ||||
| 	} | ||||
| 	return tlsConn{Conn: conn, rawConn: rawConn}, TLSInfo{conn.ConnectionState()}, nil | ||||
| 	return internal.WrapSyscallConn(rawConn, conn), TLSInfo{conn.ConnectionState()}, nil | ||||
| } | ||||
|  | ||||
| func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) { | ||||
| @@ -195,7 +196,7 @@ func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) | ||||
| 	if err := conn.Handshake(); err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	return tlsConn{Conn: conn, rawConn: rawConn}, TLSInfo{conn.ConnectionState()}, nil | ||||
| 	return internal.WrapSyscallConn(rawConn, conn), TLSInfo{conn.ConnectionState()}, nil | ||||
| } | ||||
|  | ||||
| func (c *tlsCreds) Clone() TransportCredentials { | ||||
| @@ -285,11 +286,6 @@ type OtherChannelzSecurityValue struct { | ||||
|  | ||||
| func (*OtherChannelzSecurityValue) isChannelzSecurityValue() {} | ||||
|  | ||||
| type tlsConn struct { | ||||
| 	*tls.Conn | ||||
| 	rawConn net.Conn | ||||
| } | ||||
|  | ||||
| var cipherSuiteLookup = map[uint16]string{ | ||||
| 	tls.TLS_RSA_WITH_RC4_128_SHA:                "TLS_RSA_WITH_RC4_128_SHA", | ||||
| 	tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA:           "TLS_RSA_WITH_3DES_EDE_CBC_SHA", | ||||
| @@ -309,4 +305,24 @@ var cipherSuiteLookup = map[uint16]string{ | ||||
| 	tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:   "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", | ||||
| 	tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", | ||||
| 	tls.TLS_FALLBACK_SCSV:                       "TLS_FALLBACK_SCSV", | ||||
| 	tls.TLS_RSA_WITH_AES_128_CBC_SHA256:         "TLS_RSA_WITH_AES_128_CBC_SHA256", | ||||
| 	tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", | ||||
| 	tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:   "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", | ||||
| 	tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305:    "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", | ||||
| 	tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305:  "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", | ||||
| } | ||||
|  | ||||
| // cloneTLSConfig returns a shallow clone of the exported | ||||
| // fields of cfg, ignoring the unexported sync.Once, which | ||||
| // contains a mutex and must not be copied. | ||||
| // | ||||
| // If cfg is nil, a new zero tls.Config is returned. | ||||
| // | ||||
| // TODO: inline this function if possible. | ||||
| func cloneTLSConfig(cfg *tls.Config) *tls.Config { | ||||
| 	if cfg == nil { | ||||
| 		return &tls.Config{} | ||||
| 	} | ||||
|  | ||||
| 	return cfg.Clone() | ||||
| } | ||||
|   | ||||
							
								
								
									
										57
									
								
								vendor/google.golang.org/grpc/credentials/go16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										57
									
								
								vendor/google.golang.org/grpc/credentials/go16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,57 +0,0 @@ | ||||
| // +build !go1.7 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2016 gRPC authors. | ||||
|  * | ||||
|  * 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 credentials | ||||
|  | ||||
| import ( | ||||
| 	"crypto/tls" | ||||
| ) | ||||
|  | ||||
| // cloneTLSConfig returns a shallow clone of the exported | ||||
| // fields of cfg, ignoring the unexported sync.Once, which | ||||
| // contains a mutex and must not be copied. | ||||
| // | ||||
| // If cfg is nil, a new zero tls.Config is returned. | ||||
| func cloneTLSConfig(cfg *tls.Config) *tls.Config { | ||||
| 	if cfg == nil { | ||||
| 		return &tls.Config{} | ||||
| 	} | ||||
| 	return &tls.Config{ | ||||
| 		Rand:                     cfg.Rand, | ||||
| 		Time:                     cfg.Time, | ||||
| 		Certificates:             cfg.Certificates, | ||||
| 		NameToCertificate:        cfg.NameToCertificate, | ||||
| 		GetCertificate:           cfg.GetCertificate, | ||||
| 		RootCAs:                  cfg.RootCAs, | ||||
| 		NextProtos:               cfg.NextProtos, | ||||
| 		ServerName:               cfg.ServerName, | ||||
| 		ClientAuth:               cfg.ClientAuth, | ||||
| 		ClientCAs:                cfg.ClientCAs, | ||||
| 		InsecureSkipVerify:       cfg.InsecureSkipVerify, | ||||
| 		CipherSuites:             cfg.CipherSuites, | ||||
| 		PreferServerCipherSuites: cfg.PreferServerCipherSuites, | ||||
| 		SessionTicketsDisabled:   cfg.SessionTicketsDisabled, | ||||
| 		SessionTicketKey:         cfg.SessionTicketKey, | ||||
| 		ClientSessionCache:       cfg.ClientSessionCache, | ||||
| 		MinVersion:               cfg.MinVersion, | ||||
| 		MaxVersion:               cfg.MaxVersion, | ||||
| 		CurvePreferences:         cfg.CurvePreferences, | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										59
									
								
								vendor/google.golang.org/grpc/credentials/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										59
									
								
								vendor/google.golang.org/grpc/credentials/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,59 +0,0 @@ | ||||
| // +build go1.7,!go1.8 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2016 gRPC authors. | ||||
|  * | ||||
|  * 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 credentials | ||||
|  | ||||
| import ( | ||||
| 	"crypto/tls" | ||||
| ) | ||||
|  | ||||
| // cloneTLSConfig returns a shallow clone of the exported | ||||
| // fields of cfg, ignoring the unexported sync.Once, which | ||||
| // contains a mutex and must not be copied. | ||||
| // | ||||
| // If cfg is nil, a new zero tls.Config is returned. | ||||
| func cloneTLSConfig(cfg *tls.Config) *tls.Config { | ||||
| 	if cfg == nil { | ||||
| 		return &tls.Config{} | ||||
| 	} | ||||
| 	return &tls.Config{ | ||||
| 		Rand:                        cfg.Rand, | ||||
| 		Time:                        cfg.Time, | ||||
| 		Certificates:                cfg.Certificates, | ||||
| 		NameToCertificate:           cfg.NameToCertificate, | ||||
| 		GetCertificate:              cfg.GetCertificate, | ||||
| 		RootCAs:                     cfg.RootCAs, | ||||
| 		NextProtos:                  cfg.NextProtos, | ||||
| 		ServerName:                  cfg.ServerName, | ||||
| 		ClientAuth:                  cfg.ClientAuth, | ||||
| 		ClientCAs:                   cfg.ClientCAs, | ||||
| 		InsecureSkipVerify:          cfg.InsecureSkipVerify, | ||||
| 		CipherSuites:                cfg.CipherSuites, | ||||
| 		PreferServerCipherSuites:    cfg.PreferServerCipherSuites, | ||||
| 		SessionTicketsDisabled:      cfg.SessionTicketsDisabled, | ||||
| 		SessionTicketKey:            cfg.SessionTicketKey, | ||||
| 		ClientSessionCache:          cfg.ClientSessionCache, | ||||
| 		MinVersion:                  cfg.MinVersion, | ||||
| 		MaxVersion:                  cfg.MaxVersion, | ||||
| 		CurvePreferences:            cfg.CurvePreferences, | ||||
| 		DynamicRecordSizingDisabled: cfg.DynamicRecordSizingDisabled, | ||||
| 		Renegotiation:               cfg.Renegotiation, | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										46
									
								
								vendor/google.golang.org/grpc/credentials/go18.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								vendor/google.golang.org/grpc/credentials/go18.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,46 +0,0 @@ | ||||
| // +build go1.8 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2017 gRPC authors. | ||||
|  * | ||||
|  * 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 credentials | ||||
|  | ||||
| import ( | ||||
| 	"crypto/tls" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	cipherSuiteLookup[tls.TLS_RSA_WITH_AES_128_CBC_SHA256] = "TLS_RSA_WITH_AES_128_CBC_SHA256" | ||||
| 	cipherSuiteLookup[tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256] = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" | ||||
| 	cipherSuiteLookup[tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256] = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" | ||||
| 	cipherSuiteLookup[tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305] = "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305" | ||||
| 	cipherSuiteLookup[tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305] = "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305" | ||||
| } | ||||
|  | ||||
| // cloneTLSConfig returns a shallow clone of the exported | ||||
| // fields of cfg, ignoring the unexported sync.Once, which | ||||
| // contains a mutex and must not be copied. | ||||
| // | ||||
| // If cfg is nil, a new zero tls.Config is returned. | ||||
| func cloneTLSConfig(cfg *tls.Config) *tls.Config { | ||||
| 	if cfg == nil { | ||||
| 		return &tls.Config{} | ||||
| 	} | ||||
|  | ||||
| 	return cfg.Clone() | ||||
| } | ||||
							
								
								
									
										61
									
								
								vendor/google.golang.org/grpc/credentials/internal/syscallconn.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								vendor/google.golang.org/grpc/credentials/internal/syscallconn.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| // +build !appengine | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 contains credentials-internal code. | ||||
| package internal | ||||
|  | ||||
| import ( | ||||
| 	"net" | ||||
| 	"syscall" | ||||
| ) | ||||
|  | ||||
| type sysConn = syscall.Conn | ||||
|  | ||||
| // syscallConn keeps reference of rawConn to support syscall.Conn for channelz. | ||||
| // SyscallConn() (the method in interface syscall.Conn) is explicitly | ||||
| // implemented on this type, | ||||
| // | ||||
| // Interface syscall.Conn is implemented by most net.Conn implementations (e.g. | ||||
| // TCPConn, UnixConn), but is not part of net.Conn interface. So wrapper conns | ||||
| // that embed net.Conn don't implement syscall.Conn. (Side note: tls.Conn | ||||
| // doesn't embed net.Conn, so even if syscall.Conn is part of net.Conn, it won't | ||||
| // help here). | ||||
| type syscallConn struct { | ||||
| 	net.Conn | ||||
| 	// sysConn is a type alias of syscall.Conn. It's necessary because the name | ||||
| 	// `Conn` collides with `net.Conn`. | ||||
| 	sysConn | ||||
| } | ||||
|  | ||||
| // WrapSyscallConn tries to wrap rawConn and newConn into a net.Conn that | ||||
| // implements syscall.Conn. rawConn will be used to support syscall, and newConn | ||||
| // will be used for read/write. | ||||
| // | ||||
| // This function returns newConn if rawConn doesn't implement syscall.Conn. | ||||
| func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn { | ||||
| 	sysConn, ok := rawConn.(syscall.Conn) | ||||
| 	if !ok { | ||||
| 		return newConn | ||||
| 	} | ||||
| 	return &syscallConn{ | ||||
| 		Conn:    newConn, | ||||
| 		sysConn: sysConn, | ||||
| 	} | ||||
| } | ||||
| @@ -1,8 +1,8 @@ | ||||
| // +build go1.8 | ||||
| // +build appengine | ||||
| 
 | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2017 gRPC authors. | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
| @@ -18,11 +18,13 @@ | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| package naming | ||||
| package internal | ||||
| 
 | ||||
| import "net" | ||||
| 
 | ||||
| var ( | ||||
| 	lookupHost = net.DefaultResolver.LookupHost | ||||
| 	lookupSRV  = net.DefaultResolver.LookupSRV | ||||
| import ( | ||||
| 	"net" | ||||
| ) | ||||
| 
 | ||||
| // WrapSyscallConn returns newConn on appengine. | ||||
| func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn { | ||||
| 	return newConn | ||||
| } | ||||
							
								
								
									
										23
									
								
								vendor/google.golang.org/grpc/dialoptions.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/google.golang.org/grpc/dialoptions.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,11 +19,11 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"net" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| 	"google.golang.org/grpc/internal" | ||||
| @@ -55,10 +55,11 @@ type dialOptions struct { | ||||
| 	balancerBuilder balancer.Builder | ||||
| 	// This is to support grpclb. | ||||
| 	resolverBuilder      resolver.Builder | ||||
| 	waitForHandshake     bool | ||||
| 	reqHandshake         envconfig.RequireHandshakeSetting | ||||
| 	channelzParentID     int64 | ||||
| 	disableServiceConfig bool | ||||
| 	disableRetry         bool | ||||
| 	disableHealthCheck   bool | ||||
| } | ||||
|  | ||||
| // DialOption configures how we set up the connection. | ||||
| @@ -91,10 +92,15 @@ func newFuncDialOption(f func(*dialOptions)) *funcDialOption { | ||||
| } | ||||
|  | ||||
| // WithWaitForHandshake blocks until the initial settings frame is received from | ||||
| // the server before assigning RPCs to the connection. Experimental API. | ||||
| // the server before assigning RPCs to the connection. | ||||
| // | ||||
| // Deprecated: this will become the default behavior in the 1.17 release, and | ||||
| // will be removed after the 1.18 release.  To override the default behavior in | ||||
| // the 1.17 release, either use this dial option or set the environment | ||||
| // variable GRPC_GO_READY_BEFORE_HANDSHAKE=on. | ||||
| func WithWaitForHandshake() DialOption { | ||||
| 	return newFuncDialOption(func(o *dialOptions) { | ||||
| 		o.waitForHandshake = true | ||||
| 		o.reqHandshake = envconfig.RequireHandshakeOn | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| @@ -454,9 +460,18 @@ func WithMaxHeaderListSize(s uint32) DialOption { | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WithDisableHealthCheck disables the LB channel health checking for all SubConns of this ClientConn. | ||||
| // | ||||
| // This API is EXPERIMENTAL. | ||||
| func WithDisableHealthCheck() DialOption { | ||||
| 	return newFuncDialOption(func(o *dialOptions) { | ||||
| 		o.disableHealthCheck = true | ||||
| 	}) | ||||
| } | ||||
| func defaultDialOptions() dialOptions { | ||||
| 	return dialOptions{ | ||||
| 		disableRetry: !envconfig.Retry, | ||||
| 		reqHandshake: envconfig.RequireHandshake, | ||||
| 		copts: transport.ConnectOptions{ | ||||
| 			WriteBufferSize: defaultWriteBufSize, | ||||
| 			ReadBufferSize:  defaultReadBufSize, | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/google.golang.org/grpc/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/google.golang.org/grpc/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -4,11 +4,10 @@ require ( | ||||
| 	cloud.google.com/go v0.26.0 // indirect | ||||
| 	github.com/client9/misspell v0.3.4 | ||||
| 	github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b | ||||
| 	github.com/golang/lint v0.0.0-20180702182130-06c8688daad7 | ||||
| 	github.com/golang/mock v1.1.1 | ||||
| 	github.com/golang/protobuf v1.2.0 | ||||
| 	github.com/kisielk/gotool v1.0.0 // indirect | ||||
| 	golang.org/x/lint v0.0.0-20180702182130-06c8688daad7 // indirect | ||||
| 	golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 | ||||
| 	golang.org/x/net v0.0.0-20180826012351-8a410e7b638d | ||||
| 	golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be | ||||
| 	golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/google.golang.org/grpc/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/google.golang.org/grpc/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -4,16 +4,14 @@ github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJ | ||||
| github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= | ||||
| github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= | ||||
| github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= | ||||
| github.com/golang/lint v0.0.0-20180702182130-06c8688daad7 h1:2hRPrmiwPrp3fQX967rNJIhQPtiGXdlQWAxKbKw3VHA= | ||||
| github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= | ||||
| github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= | ||||
| github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= | ||||
| github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= | ||||
| github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||
| github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= | ||||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||
| golang.org/x/lint v0.0.0-20180702182130-06c8688daad7 h1:00BeQWmeaGazuOrq8Q5K5d3/cHaGuFrZzpaHBXfrsUA= | ||||
| golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | ||||
| golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 h1:x/bBzNauLQAlE3fLku/xy92Y8QwKX5HZymrMz2IiKFc= | ||||
| golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | ||||
| golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I= | ||||
| golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||||
| golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= | ||||
|   | ||||
							
								
								
									
										71
									
								
								vendor/google.golang.org/grpc/go16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										71
									
								
								vendor/google.golang.org/grpc/go16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,71 +0,0 @@ | ||||
| // +build go1.6,!go1.7 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2016 gRPC authors. | ||||
|  * | ||||
|  * 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 grpc | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"net" | ||||
| 	"net/http" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/internal/transport" | ||||
| 	"google.golang.org/grpc/status" | ||||
| ) | ||||
|  | ||||
| // dialContext connects to the address on the named network. | ||||
| func dialContext(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 	return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address) | ||||
| } | ||||
|  | ||||
| func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error { | ||||
| 	req.Cancel = ctx.Done() | ||||
| 	if err := req.Write(conn); err != nil { | ||||
| 		return fmt.Errorf("failed to write the HTTP request: %v", err) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // toRPCErr converts an error into an error from the status package. | ||||
| func toRPCErr(err error) error { | ||||
| 	if err == nil || err == io.EOF { | ||||
| 		return err | ||||
| 	} | ||||
| 	if err == io.ErrUnexpectedEOF { | ||||
| 		return status.Error(codes.Internal, err.Error()) | ||||
| 	} | ||||
| 	if _, ok := status.FromError(err); ok { | ||||
| 		return err | ||||
| 	} | ||||
| 	switch e := err.(type) { | ||||
| 	case transport.ConnectionError: | ||||
| 		return status.Error(codes.Unavailable, e.Desc) | ||||
| 	default: | ||||
| 		switch err { | ||||
| 		case context.DeadlineExceeded: | ||||
| 			return status.Error(codes.DeadlineExceeded, err.Error()) | ||||
| 		case context.Canceled: | ||||
| 			return status.Error(codes.Canceled, err.Error()) | ||||
| 		} | ||||
| 	} | ||||
| 	return status.Error(codes.Unknown, err.Error()) | ||||
| } | ||||
							
								
								
									
										72
									
								
								vendor/google.golang.org/grpc/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										72
									
								
								vendor/google.golang.org/grpc/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,72 +0,0 @@ | ||||
| // +build go1.7 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2016 gRPC authors. | ||||
|  * | ||||
|  * 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 grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"net" | ||||
| 	"net/http" | ||||
|  | ||||
| 	netctx "golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/internal/transport" | ||||
| 	"google.golang.org/grpc/status" | ||||
| ) | ||||
|  | ||||
| // dialContext connects to the address on the named network. | ||||
| func dialContext(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 	return (&net.Dialer{}).DialContext(ctx, network, address) | ||||
| } | ||||
|  | ||||
| func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error { | ||||
| 	req = req.WithContext(ctx) | ||||
| 	if err := req.Write(conn); err != nil { | ||||
| 		return fmt.Errorf("failed to write the HTTP request: %v", err) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // toRPCErr converts an error into an error from the status package. | ||||
| func toRPCErr(err error) error { | ||||
| 	if err == nil || err == io.EOF { | ||||
| 		return err | ||||
| 	} | ||||
| 	if err == io.ErrUnexpectedEOF { | ||||
| 		return status.Error(codes.Internal, err.Error()) | ||||
| 	} | ||||
| 	if _, ok := status.FromError(err); ok { | ||||
| 		return err | ||||
| 	} | ||||
| 	switch e := err.(type) { | ||||
| 	case transport.ConnectionError: | ||||
| 		return status.Error(codes.Unavailable, e.Desc) | ||||
| 	default: | ||||
| 		switch err { | ||||
| 		case context.DeadlineExceeded, netctx.DeadlineExceeded: | ||||
| 			return status.Error(codes.DeadlineExceeded, err.Error()) | ||||
| 		case context.Canceled, netctx.Canceled: | ||||
| 			return status.Error(codes.Canceled, err.Error()) | ||||
| 		} | ||||
| 	} | ||||
| 	return status.Error(codes.Unknown, err.Error()) | ||||
| } | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/interceptor.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/interceptor.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,7 +19,7 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/net/context" | ||||
| 	"context" | ||||
| ) | ||||
|  | ||||
| // UnaryInvoker is called by UnaryClientInterceptor to complete RPCs. | ||||
|   | ||||
							
								
								
									
										167
									
								
								vendor/google.golang.org/grpc/internal/binarylog/binarylog.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										167
									
								
								vendor/google.golang.org/grpc/internal/binarylog/binarylog.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,167 @@ | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 binarylog implementation binary logging as defined in | ||||
| // https://github.com/grpc/proposal/blob/master/A16-binary-logging.md. | ||||
| package binarylog | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
|  | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| ) | ||||
|  | ||||
| // Logger is the global binary logger. It can be used to get binary logger for | ||||
| // each method. | ||||
| type Logger interface { | ||||
| 	getMethodLogger(methodName string) *MethodLogger | ||||
| } | ||||
|  | ||||
| // binLogger is the global binary logger for the binary. One of this should be | ||||
| // built at init time from the configuration (environment varialbe or flags). | ||||
| // | ||||
| // It is used to get a methodLogger for each individual method. | ||||
| var binLogger Logger | ||||
|  | ||||
| // SetLogger sets the binarg logger. | ||||
| // | ||||
| // Only call this at init time. | ||||
| func SetLogger(l Logger) { | ||||
| 	binLogger = l | ||||
| } | ||||
|  | ||||
| // GetMethodLogger returns the methodLogger for the given methodName. | ||||
| // | ||||
| // methodName should be in the format of "/service/method". | ||||
| // | ||||
| // Each methodLogger returned by this method is a new instance. This is to | ||||
| // generate sequence id within the call. | ||||
| func GetMethodLogger(methodName string) *MethodLogger { | ||||
| 	if binLogger == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return binLogger.getMethodLogger(methodName) | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	const envStr = "GRPC_BINARY_LOG_FILTER" | ||||
| 	configStr := os.Getenv(envStr) | ||||
| 	binLogger = NewLoggerFromConfigString(configStr) | ||||
| } | ||||
|  | ||||
| type methodLoggerConfig struct { | ||||
| 	// Max length of header and message. | ||||
| 	hdr, msg uint64 | ||||
| } | ||||
|  | ||||
| type logger struct { | ||||
| 	all      *methodLoggerConfig | ||||
| 	services map[string]*methodLoggerConfig | ||||
| 	methods  map[string]*methodLoggerConfig | ||||
|  | ||||
| 	blacklist map[string]struct{} | ||||
| } | ||||
|  | ||||
| // newEmptyLogger creates an empty logger. The map fields need to be filled in | ||||
| // using the set* functions. | ||||
| func newEmptyLogger() *logger { | ||||
| 	return &logger{} | ||||
| } | ||||
|  | ||||
| // Set method logger for "*". | ||||
| func (l *logger) setDefaultMethodLogger(ml *methodLoggerConfig) error { | ||||
| 	if l.all != nil { | ||||
| 		return fmt.Errorf("conflicting global rules found") | ||||
| 	} | ||||
| 	l.all = ml | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Set method logger for "service/*". | ||||
| // | ||||
| // New methodLogger with same service overrides the old one. | ||||
| func (l *logger) setServiceMethodLogger(service string, ml *methodLoggerConfig) error { | ||||
| 	if _, ok := l.services[service]; ok { | ||||
| 		return fmt.Errorf("conflicting rules for service %v found", service) | ||||
| 	} | ||||
| 	if l.services == nil { | ||||
| 		l.services = make(map[string]*methodLoggerConfig) | ||||
| 	} | ||||
| 	l.services[service] = ml | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Set method logger for "service/method". | ||||
| // | ||||
| // New methodLogger with same method overrides the old one. | ||||
| func (l *logger) setMethodMethodLogger(method string, ml *methodLoggerConfig) error { | ||||
| 	if _, ok := l.blacklist[method]; ok { | ||||
| 		return fmt.Errorf("conflicting rules for method %v found", method) | ||||
| 	} | ||||
| 	if _, ok := l.methods[method]; ok { | ||||
| 		return fmt.Errorf("conflicting rules for method %v found", method) | ||||
| 	} | ||||
| 	if l.methods == nil { | ||||
| 		l.methods = make(map[string]*methodLoggerConfig) | ||||
| 	} | ||||
| 	l.methods[method] = ml | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Set blacklist method for "-service/method". | ||||
| func (l *logger) setBlacklist(method string) error { | ||||
| 	if _, ok := l.blacklist[method]; ok { | ||||
| 		return fmt.Errorf("conflicting rules for method %v found", method) | ||||
| 	} | ||||
| 	if _, ok := l.methods[method]; ok { | ||||
| 		return fmt.Errorf("conflicting rules for method %v found", method) | ||||
| 	} | ||||
| 	if l.blacklist == nil { | ||||
| 		l.blacklist = make(map[string]struct{}) | ||||
| 	} | ||||
| 	l.blacklist[method] = struct{}{} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // getMethodLogger returns the methodLogger for the given methodName. | ||||
| // | ||||
| // methodName should be in the format of "/service/method". | ||||
| // | ||||
| // Each methodLogger returned by this method is a new instance. This is to | ||||
| // generate sequence id within the call. | ||||
| func (l *logger) getMethodLogger(methodName string) *MethodLogger { | ||||
| 	s, m, err := parseMethodName(methodName) | ||||
| 	if err != nil { | ||||
| 		grpclog.Infof("binarylogging: failed to parse %q: %v", methodName, err) | ||||
| 		return nil | ||||
| 	} | ||||
| 	if ml, ok := l.methods[s+"/"+m]; ok { | ||||
| 		return newMethodLogger(ml.hdr, ml.msg) | ||||
| 	} | ||||
| 	if _, ok := l.blacklist[s+"/"+m]; ok { | ||||
| 		return nil | ||||
| 	} | ||||
| 	if ml, ok := l.services[s]; ok { | ||||
| 		return newMethodLogger(ml.hdr, ml.msg) | ||||
| 	} | ||||
| 	if l.all == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return newMethodLogger(l.all.hdr, l.all.msg) | ||||
| } | ||||
							
								
								
									
										42
									
								
								vendor/google.golang.org/grpc/internal/binarylog/binarylog_testutil.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								vendor/google.golang.org/grpc/internal/binarylog/binarylog_testutil.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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. | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| // This file contains exported variables/functions that are exported for testing | ||||
| // only. | ||||
| // | ||||
| // An ideal way for this would be to put those in a *_test.go but in binarylog | ||||
| // package. But this doesn't work with staticcheck with go module. Error was: | ||||
| // "MdToMetadataProto not declared by package binarylog". This could be caused | ||||
| // by the way staticcheck looks for files for a certain package, which doesn't | ||||
| // support *_test.go files. | ||||
| // | ||||
| // Move those to binary_test.go when staticcheck is fixed. | ||||
|  | ||||
| package binarylog | ||||
|  | ||||
| var ( | ||||
| 	// AllLogger is a logger that logs all headers/messages for all RPCs. It's | ||||
| 	// for testing only. | ||||
| 	AllLogger = NewLoggerFromConfigString("*") | ||||
| 	// MdToMetadataProto converts metadata to a binary logging proto message. | ||||
| 	// It's for testing only. | ||||
| 	MdToMetadataProto = mdToMetadataProto | ||||
| 	// AddrToProto converts an address to a binary logging proto message. It's | ||||
| 	// for testing only. | ||||
| 	AddrToProto = addrToProto | ||||
| ) | ||||
							
								
								
									
										210
									
								
								vendor/google.golang.org/grpc/internal/binarylog/env_config.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										210
									
								
								vendor/google.golang.org/grpc/internal/binarylog/env_config.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,210 @@ | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 binarylog | ||||
|  | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"regexp" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
|  | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| ) | ||||
|  | ||||
| // NewLoggerFromConfigString reads the string and build a logger. It can be used | ||||
| // to build a new logger and assign it to binarylog.Logger. | ||||
| // | ||||
| // Example filter config strings: | ||||
| //  - "" Nothing will be logged | ||||
| //  - "*" All headers and messages will be fully logged. | ||||
| //  - "*{h}" Only headers will be logged. | ||||
| //  - "*{m:256}" Only the first 256 bytes of each message will be logged. | ||||
| //  - "Foo/*" Logs every method in service Foo | ||||
| //  - "Foo/*,-Foo/Bar" Logs every method in service Foo except method /Foo/Bar | ||||
| //  - "Foo/*,Foo/Bar{m:256}" Logs the first 256 bytes of each message in method | ||||
| //    /Foo/Bar, logs all headers and messages in every other method in service | ||||
| //    Foo. | ||||
| // | ||||
| // If two configs exist for one certain method or service, the one specified | ||||
| // later overrides the privous config. | ||||
| func NewLoggerFromConfigString(s string) Logger { | ||||
| 	if s == "" { | ||||
| 		return nil | ||||
| 	} | ||||
| 	l := newEmptyLogger() | ||||
| 	methods := strings.Split(s, ",") | ||||
| 	for _, method := range methods { | ||||
| 		if err := l.fillMethodLoggerWithConfigString(method); err != nil { | ||||
| 			grpclog.Warningf("failed to parse binary log config: %v", err) | ||||
| 			return nil | ||||
| 		} | ||||
| 	} | ||||
| 	return l | ||||
| } | ||||
|  | ||||
| // fillMethodLoggerWithConfigString parses config, creates methodLogger and adds | ||||
| // it to the right map in the logger. | ||||
| func (l *logger) fillMethodLoggerWithConfigString(config string) error { | ||||
| 	// "" is invalid. | ||||
| 	if config == "" { | ||||
| 		return errors.New("empty string is not a valid method binary logging config") | ||||
| 	} | ||||
|  | ||||
| 	// "-service/method", blacklist, no * or {} allowed. | ||||
| 	if config[0] == '-' { | ||||
| 		s, m, suffix, err := parseMethodConfigAndSuffix(config[1:]) | ||||
| 		if err != nil { | ||||
| 			return fmt.Errorf("invalid config: %q, %v", config, err) | ||||
| 		} | ||||
| 		if m == "*" { | ||||
| 			return fmt.Errorf("invalid config: %q, %v", config, "* not allowd in blacklist config") | ||||
| 		} | ||||
| 		if suffix != "" { | ||||
| 			return fmt.Errorf("invalid config: %q, %v", config, "header/message limit not allowed in blacklist config") | ||||
| 		} | ||||
| 		if err := l.setBlacklist(s + "/" + m); err != nil { | ||||
| 			return fmt.Errorf("invalid config: %v", err) | ||||
| 		} | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	// "*{h:256;m:256}" | ||||
| 	if config[0] == '*' { | ||||
| 		hdr, msg, err := parseHeaderMessageLengthConfig(config[1:]) | ||||
| 		if err != nil { | ||||
| 			return fmt.Errorf("invalid config: %q, %v", config, err) | ||||
| 		} | ||||
| 		if err := l.setDefaultMethodLogger(&methodLoggerConfig{hdr: hdr, msg: msg}); err != nil { | ||||
| 			return fmt.Errorf("invalid config: %v", err) | ||||
| 		} | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	s, m, suffix, err := parseMethodConfigAndSuffix(config) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("invalid config: %q, %v", config, err) | ||||
| 	} | ||||
| 	hdr, msg, err := parseHeaderMessageLengthConfig(suffix) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("invalid header/message length config: %q, %v", suffix, err) | ||||
| 	} | ||||
| 	if m == "*" { | ||||
| 		if err := l.setServiceMethodLogger(s, &methodLoggerConfig{hdr: hdr, msg: msg}); err != nil { | ||||
| 			return fmt.Errorf("invalid config: %v", err) | ||||
| 		} | ||||
| 	} else { | ||||
| 		if err := l.setMethodMethodLogger(s+"/"+m, &methodLoggerConfig{hdr: hdr, msg: msg}); err != nil { | ||||
| 			return fmt.Errorf("invalid config: %v", err) | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	// TODO: this const is only used by env_config now. But could be useful for | ||||
| 	// other config. Move to binarylog.go if necessary. | ||||
| 	maxUInt = ^uint64(0) | ||||
|  | ||||
| 	// For "p.s/m" plus any suffix. Suffix will be parsed again. See test for | ||||
| 	// expected output. | ||||
| 	longMethodConfigRegexpStr = `^([\w./]+)/((?:\w+)|[*])(.+)?$` | ||||
|  | ||||
| 	// For suffix from above, "{h:123,m:123}". See test for expected output. | ||||
| 	optionalLengthRegexpStr      = `(?::(\d+))?` // Optional ":123". | ||||
| 	headerConfigRegexpStr        = `^{h` + optionalLengthRegexpStr + `}$` | ||||
| 	messageConfigRegexpStr       = `^{m` + optionalLengthRegexpStr + `}$` | ||||
| 	headerMessageConfigRegexpStr = `^{h` + optionalLengthRegexpStr + `;m` + optionalLengthRegexpStr + `}$` | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	longMethodConfigRegexp    = regexp.MustCompile(longMethodConfigRegexpStr) | ||||
| 	headerConfigRegexp        = regexp.MustCompile(headerConfigRegexpStr) | ||||
| 	messageConfigRegexp       = regexp.MustCompile(messageConfigRegexpStr) | ||||
| 	headerMessageConfigRegexp = regexp.MustCompile(headerMessageConfigRegexpStr) | ||||
| ) | ||||
|  | ||||
| // Turn "service/method{h;m}" into "service", "method", "{h;m}". | ||||
| func parseMethodConfigAndSuffix(c string) (service, method, suffix string, _ error) { | ||||
| 	// Regexp result: | ||||
| 	// | ||||
| 	// in:  "p.s/m{h:123,m:123}", | ||||
| 	// out: []string{"p.s/m{h:123,m:123}", "p.s", "m", "{h:123,m:123}"}, | ||||
| 	match := longMethodConfigRegexp.FindStringSubmatch(c) | ||||
| 	if match == nil { | ||||
| 		return "", "", "", fmt.Errorf("%q contains invalid substring", c) | ||||
| 	} | ||||
| 	service = match[1] | ||||
| 	method = match[2] | ||||
| 	suffix = match[3] | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // Turn "{h:123;m:345}" into 123, 345. | ||||
| // | ||||
| // Return maxUInt if length is unspecified. | ||||
| func parseHeaderMessageLengthConfig(c string) (hdrLenStr, msgLenStr uint64, err error) { | ||||
| 	if c == "" { | ||||
| 		return maxUInt, maxUInt, nil | ||||
| 	} | ||||
| 	// Header config only. | ||||
| 	if match := headerConfigRegexp.FindStringSubmatch(c); match != nil { | ||||
| 		if s := match[1]; s != "" { | ||||
| 			hdrLenStr, err = strconv.ParseUint(s, 10, 64) | ||||
| 			if err != nil { | ||||
| 				return 0, 0, fmt.Errorf("failed to convert %q to uint", s) | ||||
| 			} | ||||
| 			return hdrLenStr, 0, nil | ||||
| 		} | ||||
| 		return maxUInt, 0, nil | ||||
| 	} | ||||
|  | ||||
| 	// Message config only. | ||||
| 	if match := messageConfigRegexp.FindStringSubmatch(c); match != nil { | ||||
| 		if s := match[1]; s != "" { | ||||
| 			msgLenStr, err = strconv.ParseUint(s, 10, 64) | ||||
| 			if err != nil { | ||||
| 				return 0, 0, fmt.Errorf("Failed to convert %q to uint", s) | ||||
| 			} | ||||
| 			return 0, msgLenStr, nil | ||||
| 		} | ||||
| 		return 0, maxUInt, nil | ||||
| 	} | ||||
|  | ||||
| 	// Header and message config both. | ||||
| 	if match := headerMessageConfigRegexp.FindStringSubmatch(c); match != nil { | ||||
| 		// Both hdr and msg are specified, but one or two of them might be empty. | ||||
| 		hdrLenStr = maxUInt | ||||
| 		msgLenStr = maxUInt | ||||
| 		if s := match[1]; s != "" { | ||||
| 			hdrLenStr, err = strconv.ParseUint(s, 10, 64) | ||||
| 			if err != nil { | ||||
| 				return 0, 0, fmt.Errorf("Failed to convert %q to uint", s) | ||||
| 			} | ||||
| 		} | ||||
| 		if s := match[2]; s != "" { | ||||
| 			msgLenStr, err = strconv.ParseUint(s, 10, 64) | ||||
| 			if err != nil { | ||||
| 				return 0, 0, fmt.Errorf("Failed to convert %q to uint", s) | ||||
| 			} | ||||
| 		} | ||||
| 		return hdrLenStr, msgLenStr, nil | ||||
| 	} | ||||
| 	return 0, 0, fmt.Errorf("%q contains invalid substring", c) | ||||
| } | ||||
							
								
								
									
										426
									
								
								vendor/google.golang.org/grpc/internal/binarylog/method_logger.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										426
									
								
								vendor/google.golang.org/grpc/internal/binarylog/method_logger.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,426 @@ | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 binarylog | ||||
|  | ||||
| import ( | ||||
| 	"net" | ||||
| 	"strings" | ||||
| 	"sync/atomic" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/golang/protobuf/proto" | ||||
| 	"github.com/golang/protobuf/ptypes" | ||||
| 	pb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
| 	"google.golang.org/grpc/status" | ||||
| ) | ||||
|  | ||||
| type callIDGenerator struct { | ||||
| 	id uint64 | ||||
| } | ||||
|  | ||||
| func (g *callIDGenerator) next() uint64 { | ||||
| 	id := atomic.AddUint64(&g.id, 1) | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // reset is for testing only, and doesn't need to be thread safe. | ||||
| func (g *callIDGenerator) reset() { | ||||
| 	g.id = 0 | ||||
| } | ||||
|  | ||||
| var idGen callIDGenerator | ||||
|  | ||||
| // MethodLogger is the sub-logger for each method. | ||||
| type MethodLogger struct { | ||||
| 	headerMaxLen, messageMaxLen uint64 | ||||
|  | ||||
| 	callID          uint64 | ||||
| 	idWithinCallGen *callIDGenerator | ||||
|  | ||||
| 	sink Sink // TODO(blog): make this plugable. | ||||
| } | ||||
|  | ||||
| func newMethodLogger(h, m uint64) *MethodLogger { | ||||
| 	return &MethodLogger{ | ||||
| 		headerMaxLen:  h, | ||||
| 		messageMaxLen: m, | ||||
|  | ||||
| 		callID:          idGen.next(), | ||||
| 		idWithinCallGen: &callIDGenerator{}, | ||||
|  | ||||
| 		sink: defaultSink, // TODO(blog): make it plugable. | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Log creates a proto binary log entry, and logs it to the sink. | ||||
| func (ml *MethodLogger) Log(c LogEntryConfig) { | ||||
| 	m := c.toProto() | ||||
| 	timestamp, _ := ptypes.TimestampProto(time.Now()) | ||||
| 	m.Timestamp = timestamp | ||||
| 	m.CallId = ml.callID | ||||
| 	m.SequenceIdWithinCall = ml.idWithinCallGen.next() | ||||
|  | ||||
| 	switch pay := m.Payload.(type) { | ||||
| 	case *pb.GrpcLogEntry_ClientHeader: | ||||
| 		m.PayloadTruncated = ml.truncateMetadata(pay.ClientHeader.GetMetadata()) | ||||
| 	case *pb.GrpcLogEntry_ServerHeader: | ||||
| 		m.PayloadTruncated = ml.truncateMetadata(pay.ServerHeader.GetMetadata()) | ||||
| 	case *pb.GrpcLogEntry_Message: | ||||
| 		m.PayloadTruncated = ml.truncateMessage(pay.Message) | ||||
| 	} | ||||
|  | ||||
| 	ml.sink.Write(m) | ||||
| } | ||||
|  | ||||
| func (ml *MethodLogger) truncateMetadata(mdPb *pb.Metadata) (truncated bool) { | ||||
| 	if ml.headerMaxLen == maxUInt { | ||||
| 		return false | ||||
| 	} | ||||
| 	var ( | ||||
| 		bytesLimit = ml.headerMaxLen | ||||
| 		index      int | ||||
| 	) | ||||
| 	// At the end of the loop, index will be the first entry where the total | ||||
| 	// size is greater than the limit: | ||||
| 	// | ||||
| 	// len(entry[:index]) <= ml.hdr && len(entry[:index+1]) > ml.hdr. | ||||
| 	for ; index < len(mdPb.Entry); index++ { | ||||
| 		entry := mdPb.Entry[index] | ||||
| 		if entry.Key == "grpc-trace-bin" { | ||||
| 			// "grpc-trace-bin" is a special key. It's kept in the log entry, | ||||
| 			// but not counted towards the size limit. | ||||
| 			continue | ||||
| 		} | ||||
| 		currentEntryLen := uint64(len(entry.Value)) | ||||
| 		if currentEntryLen > bytesLimit { | ||||
| 			break | ||||
| 		} | ||||
| 		bytesLimit -= currentEntryLen | ||||
| 	} | ||||
| 	truncated = index < len(mdPb.Entry) | ||||
| 	mdPb.Entry = mdPb.Entry[:index] | ||||
| 	return truncated | ||||
| } | ||||
|  | ||||
| func (ml *MethodLogger) truncateMessage(msgPb *pb.Message) (truncated bool) { | ||||
| 	if ml.messageMaxLen == maxUInt { | ||||
| 		return false | ||||
| 	} | ||||
| 	if ml.messageMaxLen >= uint64(len(msgPb.Data)) { | ||||
| 		return false | ||||
| 	} | ||||
| 	msgPb.Data = msgPb.Data[:ml.messageMaxLen] | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // LogEntryConfig represents the configuration for binary log entry. | ||||
| type LogEntryConfig interface { | ||||
| 	toProto() *pb.GrpcLogEntry | ||||
| } | ||||
|  | ||||
| // ClientHeader configs the binary log entry to be a ClientHeader entry. | ||||
| type ClientHeader struct { | ||||
| 	OnClientSide bool | ||||
| 	Header       metadata.MD | ||||
| 	MethodName   string | ||||
| 	Authority    string | ||||
| 	Timeout      time.Duration | ||||
| 	// PeerAddr is required only when it's on server side. | ||||
| 	PeerAddr net.Addr | ||||
| } | ||||
|  | ||||
| func (c *ClientHeader) toProto() *pb.GrpcLogEntry { | ||||
| 	// This function doesn't need to set all the fields (e.g. seq ID). The Log | ||||
| 	// function will set the fields when necessary. | ||||
| 	clientHeader := &pb.ClientHeader{ | ||||
| 		Metadata:   mdToMetadataProto(c.Header), | ||||
| 		MethodName: c.MethodName, | ||||
| 		Authority:  c.Authority, | ||||
| 	} | ||||
| 	if c.Timeout > 0 { | ||||
| 		clientHeader.Timeout = ptypes.DurationProto(c.Timeout) | ||||
| 	} | ||||
| 	ret := &pb.GrpcLogEntry{ | ||||
| 		Type: pb.GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER, | ||||
| 		Payload: &pb.GrpcLogEntry_ClientHeader{ | ||||
| 			ClientHeader: clientHeader, | ||||
| 		}, | ||||
| 	} | ||||
| 	if c.OnClientSide { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_CLIENT | ||||
| 	} else { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_SERVER | ||||
| 	} | ||||
| 	if c.PeerAddr != nil { | ||||
| 		ret.Peer = addrToProto(c.PeerAddr) | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| // ServerHeader configs the binary log entry to be a ServerHeader entry. | ||||
| type ServerHeader struct { | ||||
| 	OnClientSide bool | ||||
| 	Header       metadata.MD | ||||
| 	// PeerAddr is required only when it's on client side. | ||||
| 	PeerAddr net.Addr | ||||
| } | ||||
|  | ||||
| func (c *ServerHeader) toProto() *pb.GrpcLogEntry { | ||||
| 	ret := &pb.GrpcLogEntry{ | ||||
| 		Type: pb.GrpcLogEntry_EVENT_TYPE_SERVER_HEADER, | ||||
| 		Payload: &pb.GrpcLogEntry_ServerHeader{ | ||||
| 			ServerHeader: &pb.ServerHeader{ | ||||
| 				Metadata: mdToMetadataProto(c.Header), | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if c.OnClientSide { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_CLIENT | ||||
| 	} else { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_SERVER | ||||
| 	} | ||||
| 	if c.PeerAddr != nil { | ||||
| 		ret.Peer = addrToProto(c.PeerAddr) | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| // ClientMessage configs the binary log entry to be a ClientMessage entry. | ||||
| type ClientMessage struct { | ||||
| 	OnClientSide bool | ||||
| 	// Message can be a proto.Message or []byte. Other messages formats are not | ||||
| 	// supported. | ||||
| 	Message interface{} | ||||
| } | ||||
|  | ||||
| func (c *ClientMessage) toProto() *pb.GrpcLogEntry { | ||||
| 	var ( | ||||
| 		data []byte | ||||
| 		err  error | ||||
| 	) | ||||
| 	if m, ok := c.Message.(proto.Message); ok { | ||||
| 		data, err = proto.Marshal(m) | ||||
| 		if err != nil { | ||||
| 			grpclog.Infof("binarylogging: failed to marshal proto message: %v", err) | ||||
| 		} | ||||
| 	} else if b, ok := c.Message.([]byte); ok { | ||||
| 		data = b | ||||
| 	} else { | ||||
| 		grpclog.Infof("binarylogging: message to log is neither proto.message nor []byte") | ||||
| 	} | ||||
| 	ret := &pb.GrpcLogEntry{ | ||||
| 		Type: pb.GrpcLogEntry_EVENT_TYPE_CLIENT_MESSAGE, | ||||
| 		Payload: &pb.GrpcLogEntry_Message{ | ||||
| 			Message: &pb.Message{ | ||||
| 				Length: uint32(len(data)), | ||||
| 				Data:   data, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if c.OnClientSide { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_CLIENT | ||||
| 	} else { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_SERVER | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| // ServerMessage configs the binary log entry to be a ServerMessage entry. | ||||
| type ServerMessage struct { | ||||
| 	OnClientSide bool | ||||
| 	// Message can be a proto.Message or []byte. Other messages formats are not | ||||
| 	// supported. | ||||
| 	Message interface{} | ||||
| } | ||||
|  | ||||
| func (c *ServerMessage) toProto() *pb.GrpcLogEntry { | ||||
| 	var ( | ||||
| 		data []byte | ||||
| 		err  error | ||||
| 	) | ||||
| 	if m, ok := c.Message.(proto.Message); ok { | ||||
| 		data, err = proto.Marshal(m) | ||||
| 		if err != nil { | ||||
| 			grpclog.Infof("binarylogging: failed to marshal proto message: %v", err) | ||||
| 		} | ||||
| 	} else if b, ok := c.Message.([]byte); ok { | ||||
| 		data = b | ||||
| 	} else { | ||||
| 		grpclog.Infof("binarylogging: message to log is neither proto.message nor []byte") | ||||
| 	} | ||||
| 	ret := &pb.GrpcLogEntry{ | ||||
| 		Type: pb.GrpcLogEntry_EVENT_TYPE_SERVER_MESSAGE, | ||||
| 		Payload: &pb.GrpcLogEntry_Message{ | ||||
| 			Message: &pb.Message{ | ||||
| 				Length: uint32(len(data)), | ||||
| 				Data:   data, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if c.OnClientSide { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_CLIENT | ||||
| 	} else { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_SERVER | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| // ClientHalfClose configs the binary log entry to be a ClientHalfClose entry. | ||||
| type ClientHalfClose struct { | ||||
| 	OnClientSide bool | ||||
| } | ||||
|  | ||||
| func (c *ClientHalfClose) toProto() *pb.GrpcLogEntry { | ||||
| 	ret := &pb.GrpcLogEntry{ | ||||
| 		Type:    pb.GrpcLogEntry_EVENT_TYPE_CLIENT_HALF_CLOSE, | ||||
| 		Payload: nil, // No payload here. | ||||
| 	} | ||||
| 	if c.OnClientSide { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_CLIENT | ||||
| 	} else { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_SERVER | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| // ServerTrailer configs the binary log entry to be a ServerTrailer entry. | ||||
| type ServerTrailer struct { | ||||
| 	OnClientSide bool | ||||
| 	Trailer      metadata.MD | ||||
| 	// Err is the status error. | ||||
| 	Err error | ||||
| 	// PeerAddr is required only when it's on client side and the RPC is trailer | ||||
| 	// only. | ||||
| 	PeerAddr net.Addr | ||||
| } | ||||
|  | ||||
| func (c *ServerTrailer) toProto() *pb.GrpcLogEntry { | ||||
| 	st, ok := status.FromError(c.Err) | ||||
| 	if !ok { | ||||
| 		grpclog.Info("binarylogging: error in trailer is not a status error") | ||||
| 	} | ||||
| 	var ( | ||||
| 		detailsBytes []byte | ||||
| 		err          error | ||||
| 	) | ||||
| 	stProto := st.Proto() | ||||
| 	if stProto != nil && len(stProto.Details) != 0 { | ||||
| 		detailsBytes, err = proto.Marshal(stProto) | ||||
| 		if err != nil { | ||||
| 			grpclog.Infof("binarylogging: failed to marshal status proto: %v", err) | ||||
| 		} | ||||
| 	} | ||||
| 	ret := &pb.GrpcLogEntry{ | ||||
| 		Type: pb.GrpcLogEntry_EVENT_TYPE_SERVER_TRAILER, | ||||
| 		Payload: &pb.GrpcLogEntry_Trailer{ | ||||
| 			Trailer: &pb.Trailer{ | ||||
| 				Metadata:      mdToMetadataProto(c.Trailer), | ||||
| 				StatusCode:    uint32(st.Code()), | ||||
| 				StatusMessage: st.Message(), | ||||
| 				StatusDetails: detailsBytes, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if c.OnClientSide { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_CLIENT | ||||
| 	} else { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_SERVER | ||||
| 	} | ||||
| 	if c.PeerAddr != nil { | ||||
| 		ret.Peer = addrToProto(c.PeerAddr) | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| // Cancel configs the binary log entry to be a Cancel entry. | ||||
| type Cancel struct { | ||||
| 	OnClientSide bool | ||||
| } | ||||
|  | ||||
| func (c *Cancel) toProto() *pb.GrpcLogEntry { | ||||
| 	ret := &pb.GrpcLogEntry{ | ||||
| 		Type:    pb.GrpcLogEntry_EVENT_TYPE_CANCEL, | ||||
| 		Payload: nil, | ||||
| 	} | ||||
| 	if c.OnClientSide { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_CLIENT | ||||
| 	} else { | ||||
| 		ret.Logger = pb.GrpcLogEntry_LOGGER_SERVER | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| // metadataKeyOmit returns whether the metadata entry with this key should be | ||||
| // omitted. | ||||
| func metadataKeyOmit(key string) bool { | ||||
| 	switch key { | ||||
| 	case "lb-token", ":path", ":authority", "content-encoding", "content-type", "user-agent", "te": | ||||
| 		return true | ||||
| 	case "grpc-trace-bin": // grpc-trace-bin is special because it's visiable to users. | ||||
| 		return false | ||||
| 	} | ||||
| 	if strings.HasPrefix(key, "grpc-") { | ||||
| 		return true | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func mdToMetadataProto(md metadata.MD) *pb.Metadata { | ||||
| 	ret := &pb.Metadata{} | ||||
| 	for k, vv := range md { | ||||
| 		if metadataKeyOmit(k) { | ||||
| 			continue | ||||
| 		} | ||||
| 		for _, v := range vv { | ||||
| 			ret.Entry = append(ret.Entry, | ||||
| 				&pb.MetadataEntry{ | ||||
| 					Key:   k, | ||||
| 					Value: []byte(v), | ||||
| 				}, | ||||
| 			) | ||||
| 		} | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| func addrToProto(addr net.Addr) *pb.Address { | ||||
| 	ret := &pb.Address{} | ||||
| 	switch a := addr.(type) { | ||||
| 	case *net.TCPAddr: | ||||
| 		if a.IP.To4() != nil { | ||||
| 			ret.Type = pb.Address_TYPE_IPV4 | ||||
| 		} else if a.IP.To16() != nil { | ||||
| 			ret.Type = pb.Address_TYPE_IPV6 | ||||
| 		} else { | ||||
| 			ret.Type = pb.Address_TYPE_UNKNOWN | ||||
| 			// Do not set address and port fields. | ||||
| 			break | ||||
| 		} | ||||
| 		ret.Address = a.IP.String() | ||||
| 		ret.IpPort = uint32(a.Port) | ||||
| 	case *net.UnixAddr: | ||||
| 		ret.Type = pb.Address_TYPE_UNIX | ||||
| 		ret.Address = a.String() | ||||
| 	default: | ||||
| 		ret.Type = pb.Address_TYPE_UNKNOWN | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
							
								
								
									
										33
									
								
								vendor/google.golang.org/grpc/internal/binarylog/regenerate.sh
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								vendor/google.golang.org/grpc/internal/binarylog/regenerate.sh
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| #!/bin/bash | ||||
| # Copyright 2018 gRPC authors. | ||||
| # | ||||
| # 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. | ||||
|  | ||||
| set -eux -o pipefail | ||||
|  | ||||
| TMP=$(mktemp -d) | ||||
|  | ||||
| function finish { | ||||
|   rm -rf "$TMP" | ||||
| } | ||||
| trap finish EXIT | ||||
|  | ||||
| pushd "$TMP" | ||||
| mkdir -p grpc/binarylog/grpc_binarylog_v1 | ||||
| curl https://raw.githubusercontent.com/grpc/grpc-proto/master/grpc/binlog/v1/binarylog.proto > grpc/binarylog/grpc_binarylog_v1/binarylog.proto | ||||
|  | ||||
| protoc --go_out=plugins=grpc,paths=source_relative:. -I. grpc/binarylog/grpc_binarylog_v1/*.proto | ||||
| popd | ||||
| rm -f ./grpc_binarylog_v1/*.pb.go | ||||
| cp "$TMP"/grpc/binarylog/grpc_binarylog_v1/*.pb.go ../../binarylog/grpc_binarylog_v1/ | ||||
|  | ||||
							
								
								
									
										162
									
								
								vendor/google.golang.org/grpc/internal/binarylog/sink.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										162
									
								
								vendor/google.golang.org/grpc/internal/binarylog/sink.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,162 @@ | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 binarylog | ||||
|  | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"encoding/binary" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/golang/protobuf/proto" | ||||
| 	pb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	defaultSink Sink = &noopSink{} // TODO(blog): change this default (file in /tmp). | ||||
| ) | ||||
|  | ||||
| // SetDefaultSink sets the sink where binary logs will be written to. | ||||
| // | ||||
| // Not thread safe. Only set during initialization. | ||||
| func SetDefaultSink(s Sink) { | ||||
| 	if defaultSink != nil { | ||||
| 		defaultSink.Close() | ||||
| 	} | ||||
| 	defaultSink = s | ||||
| } | ||||
|  | ||||
| // Sink writes log entry into the binary log sink. | ||||
| type Sink interface { | ||||
| 	// Write will be called to write the log entry into the sink. | ||||
| 	// | ||||
| 	// It should be thread-safe so it can be called in parallel. | ||||
| 	Write(*pb.GrpcLogEntry) error | ||||
| 	// Close will be called when the Sink is replaced by a new Sink. | ||||
| 	Close() error | ||||
| } | ||||
|  | ||||
| type noopSink struct{} | ||||
|  | ||||
| func (ns *noopSink) Write(*pb.GrpcLogEntry) error { return nil } | ||||
| func (ns *noopSink) Close() error                 { return nil } | ||||
|  | ||||
| // newWriterSink creates a binary log sink with the given writer. | ||||
| // | ||||
| // Write() marshalls the proto message and writes it to the given writer. Each | ||||
| // message is prefixed with a 4 byte big endian unsigned integer as the length. | ||||
| // | ||||
| // No buffer is done, Close() doesn't try to close the writer. | ||||
| func newWriterSink(w io.Writer) *writerSink { | ||||
| 	return &writerSink{out: w} | ||||
| } | ||||
|  | ||||
| type writerSink struct { | ||||
| 	out io.Writer | ||||
| } | ||||
|  | ||||
| func (ws *writerSink) Write(e *pb.GrpcLogEntry) error { | ||||
| 	b, err := proto.Marshal(e) | ||||
| 	if err != nil { | ||||
| 		grpclog.Infof("binary logging: failed to marshal proto message: %v", err) | ||||
| 	} | ||||
| 	hdr := make([]byte, 4) | ||||
| 	binary.BigEndian.PutUint32(hdr, uint32(len(b))) | ||||
| 	if _, err := ws.out.Write(hdr); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if _, err := ws.out.Write(b); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (ws *writerSink) Close() error { return nil } | ||||
|  | ||||
| type bufWriteCloserSink struct { | ||||
| 	mu     sync.Mutex | ||||
| 	closer io.Closer | ||||
| 	out    *writerSink   // out is built on buf. | ||||
| 	buf    *bufio.Writer // buf is kept for flush. | ||||
|  | ||||
| 	writeStartOnce sync.Once | ||||
| 	writeTicker    *time.Ticker | ||||
| } | ||||
|  | ||||
| func (fs *bufWriteCloserSink) Write(e *pb.GrpcLogEntry) error { | ||||
| 	// Start the write loop when Write is called. | ||||
| 	fs.writeStartOnce.Do(fs.startFlushGoroutine) | ||||
| 	fs.mu.Lock() | ||||
| 	if err := fs.out.Write(e); err != nil { | ||||
| 		fs.mu.Unlock() | ||||
| 		return err | ||||
| 	} | ||||
| 	fs.mu.Unlock() | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	bufFlushDuration = 60 * time.Second | ||||
| ) | ||||
|  | ||||
| func (fs *bufWriteCloserSink) startFlushGoroutine() { | ||||
| 	fs.writeTicker = time.NewTicker(bufFlushDuration) | ||||
| 	go func() { | ||||
| 		for range fs.writeTicker.C { | ||||
| 			fs.mu.Lock() | ||||
| 			fs.buf.Flush() | ||||
| 			fs.mu.Unlock() | ||||
| 		} | ||||
| 	}() | ||||
| } | ||||
|  | ||||
| func (fs *bufWriteCloserSink) Close() error { | ||||
| 	if fs.writeTicker != nil { | ||||
| 		fs.writeTicker.Stop() | ||||
| 	} | ||||
| 	fs.mu.Lock() | ||||
| 	fs.buf.Flush() | ||||
| 	fs.closer.Close() | ||||
| 	fs.out.Close() | ||||
| 	fs.mu.Unlock() | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func newBufWriteCloserSink(o io.WriteCloser) Sink { | ||||
| 	bufW := bufio.NewWriter(o) | ||||
| 	return &bufWriteCloserSink{ | ||||
| 		closer: o, | ||||
| 		out:    newWriterSink(bufW), | ||||
| 		buf:    bufW, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // NewTempFileSink creates a temp file and returns a Sink that writes to this | ||||
| // file. | ||||
| func NewTempFileSink() (Sink, error) { | ||||
| 	tempFile, err := ioutil.TempFile("/tmp", "grpcgo_binarylog_*.txt") | ||||
| 	if err != nil { | ||||
| 		return nil, fmt.Errorf("failed to create temp file: %v", err) | ||||
| 	} | ||||
| 	return newBufWriteCloserSink(tempFile), nil | ||||
| } | ||||
| @@ -1,5 +1,3 @@ | ||||
| // +build go1.9,!appengine | ||||
| 
 | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
| @@ -18,18 +16,26 @@ | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| package credentials | ||||
| package binarylog | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"syscall" | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| // implements the syscall.Conn interface | ||||
| func (c tlsConn) SyscallConn() (syscall.RawConn, error) { | ||||
| 	conn, ok := c.rawConn.(syscall.Conn) | ||||
| 	if !ok { | ||||
| 		return nil, errors.New("RawConn does not implement syscall.Conn") | ||||
| // parseMethodName splits service and method from the input. It expects format | ||||
| // "/service/method". | ||||
| // | ||||
| // TODO: move to internal/grpcutil. | ||||
| func parseMethodName(methodName string) (service, method string, _ error) { | ||||
| 	if !strings.HasPrefix(methodName, "/") { | ||||
| 		return "", "", errors.New("invalid method name: should start with /") | ||||
| 	} | ||||
| 	return conn.SyscallConn() | ||||
| 	methodName = methodName[1:] | ||||
| 
 | ||||
| 	pos := strings.LastIndex(methodName, "/") | ||||
| 	if pos < 0 { | ||||
| 		return "", "", errors.New("invalid method name: suffix /method is missing") | ||||
| 	} | ||||
| 	return methodName[:pos], methodName[pos+1:], nil | ||||
| } | ||||
							
								
								
									
										12
									
								
								vendor/google.golang.org/grpc/internal/channelz/funcs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/google.golang.org/grpc/internal/channelz/funcs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -558,7 +558,7 @@ func (c *channelMap) GetServerSockets(id int64, startID int64) ([]*SocketMetric, | ||||
| 		ids = append(ids, k) | ||||
| 	} | ||||
| 	sort.Sort(int64Slice(ids)) | ||||
| 	idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= id }) | ||||
| 	idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= startID }) | ||||
| 	count := 0 | ||||
| 	var end bool | ||||
| 	for i, v := range ids[idx:] { | ||||
| @@ -601,8 +601,11 @@ func (c *channelMap) GetChannel(id int64) *ChannelMetric { | ||||
| 	} | ||||
| 	cm.NestedChans = copyMap(cn.nestedChans) | ||||
| 	cm.SubChans = copyMap(cn.subChans) | ||||
| 	// cn.c can be set to &dummyChannel{} when deleteSelfFromMap is called. Save a copy of cn.c when | ||||
| 	// holding the lock to prevent potential data race. | ||||
| 	chanCopy := cn.c | ||||
| 	c.mu.RUnlock() | ||||
| 	cm.ChannelData = cn.c.ChannelzMetric() | ||||
| 	cm.ChannelData = chanCopy.ChannelzMetric() | ||||
| 	cm.ID = cn.id | ||||
| 	cm.RefName = cn.refName | ||||
| 	cm.Trace = cn.trace.dumpData() | ||||
| @@ -620,8 +623,11 @@ func (c *channelMap) GetSubChannel(id int64) *SubChannelMetric { | ||||
| 		return nil | ||||
| 	} | ||||
| 	cm.Sockets = copyMap(sc.sockets) | ||||
| 	// sc.c can be set to &dummyChannel{} when deleteSelfFromMap is called. Save a copy of sc.c when | ||||
| 	// holding the lock to prevent potential data race. | ||||
| 	chanCopy := sc.c | ||||
| 	c.mu.RUnlock() | ||||
| 	cm.ChannelData = sc.c.ChannelzMetric() | ||||
| 	cm.ChannelData = chanCopy.ChannelzMetric() | ||||
| 	cm.ID = sc.id | ||||
| 	cm.RefName = sc.refName | ||||
| 	cm.Trace = sc.trace.dumpData() | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/internal/channelz/types_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/internal/channelz/types_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| // +build !appengine,go1.7 | ||||
| // +build !appengine | ||||
|  | ||||
| /* | ||||
|  * | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/internal/channelz/types_nonlinux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/internal/channelz/types_nonlinux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| // +build !linux appengine !go1.7 | ||||
| // +build !linux appengine | ||||
|  | ||||
| /* | ||||
|  * | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| // +build linux,go1.9,!appengine | ||||
| // +build linux,!appengine | ||||
| 
 | ||||
| /* | ||||
|  * | ||||
| @@ -1,4 +1,4 @@ | ||||
| // +build !linux !go1.9 appengine | ||||
| // +build !linux appengine | ||||
| 
 | ||||
| /* | ||||
|  * | ||||
							
								
								
									
										34
									
								
								vendor/google.golang.org/grpc/internal/envconfig/envconfig.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								vendor/google.golang.org/grpc/internal/envconfig/envconfig.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -27,9 +27,43 @@ import ( | ||||
| const ( | ||||
| 	prefix              = "GRPC_GO_" | ||||
| 	retryStr            = prefix + "RETRY" | ||||
| 	requireHandshakeStr = prefix + "REQUIRE_HANDSHAKE" | ||||
| ) | ||||
|  | ||||
| // RequireHandshakeSetting describes the settings for handshaking. | ||||
| type RequireHandshakeSetting int | ||||
|  | ||||
| const ( | ||||
| 	// RequireHandshakeHybrid (default, deprecated) indicates to wait for | ||||
| 	// handshake before considering a connection ready, but wait before | ||||
| 	// considering successful. | ||||
| 	RequireHandshakeHybrid RequireHandshakeSetting = iota | ||||
| 	// RequireHandshakeOn (default after the 1.17 release) indicates to wait | ||||
| 	// for handshake before considering a connection ready/successful. | ||||
| 	RequireHandshakeOn | ||||
| 	// RequireHandshakeOff indicates to not wait for handshake before | ||||
| 	// considering a connection ready/successful. | ||||
| 	RequireHandshakeOff | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// Retry is set if retry is explicitly enabled via "GRPC_GO_RETRY=on". | ||||
| 	Retry = strings.EqualFold(os.Getenv(retryStr), "on") | ||||
| 	// RequireHandshake is set based upon the GRPC_GO_REQUIRE_HANDSHAKE | ||||
| 	// environment variable. | ||||
| 	// | ||||
| 	// Will be removed after the 1.18 release. | ||||
| 	RequireHandshake RequireHandshakeSetting | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	switch strings.ToLower(os.Getenv(requireHandshakeStr)) { | ||||
| 	case "on": | ||||
| 		RequireHandshake = RequireHandshakeOn | ||||
| 	case "off": | ||||
| 		RequireHandshake = RequireHandshakeOff | ||||
| 	case "hybrid": | ||||
| 		// Will be removed after the 1.17 release. | ||||
| 		RequireHandshake = RequireHandshakeHybrid | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										61
									
								
								vendor/google.golang.org/grpc/internal/grpcsync/event.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								vendor/google.golang.org/grpc/internal/grpcsync/event.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 grpcsync implements additional synchronization primitives built upon | ||||
| // the sync package. | ||||
| package grpcsync | ||||
|  | ||||
| import ( | ||||
| 	"sync" | ||||
| 	"sync/atomic" | ||||
| ) | ||||
|  | ||||
| // Event represents a one-time event that may occur in the future. | ||||
| type Event struct { | ||||
| 	fired int32 | ||||
| 	c     chan struct{} | ||||
| 	o     sync.Once | ||||
| } | ||||
|  | ||||
| // Fire causes e to complete.  It is safe to call multiple times, and | ||||
| // concurrently.  It returns true iff this call to Fire caused the signaling | ||||
| // channel returned by Done to close. | ||||
| func (e *Event) Fire() bool { | ||||
| 	ret := false | ||||
| 	e.o.Do(func() { | ||||
| 		atomic.StoreInt32(&e.fired, 1) | ||||
| 		close(e.c) | ||||
| 		ret = true | ||||
| 	}) | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| // Done returns a channel that will be closed when Fire is called. | ||||
| func (e *Event) Done() <-chan struct{} { | ||||
| 	return e.c | ||||
| } | ||||
|  | ||||
| // HasFired returns true if Fire has been called. | ||||
| func (e *Event) HasFired() bool { | ||||
| 	return atomic.LoadInt32(&e.fired) == 1 | ||||
| } | ||||
|  | ||||
| // NewEvent returns a new, ready-to-use Event. | ||||
| func NewEvent() *Event { | ||||
| 	return &Event{c: make(chan struct{})} | ||||
| } | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/internal/internal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/internal/internal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,7 +20,7 @@ | ||||
| // symbols to avoid circular dependencies. | ||||
| package internal | ||||
|  | ||||
| import "golang.org/x/net/context" | ||||
| import "context" | ||||
|  | ||||
| var ( | ||||
| 	// WithContextDialer is exported by clientconn.go | ||||
|   | ||||
							
								
								
									
										114
									
								
								vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,114 @@ | ||||
| // +build !appengine | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 syscall provides functionalities that grpc uses to get low-level operating system | ||||
| // stats/info. | ||||
| package syscall | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net" | ||||
| 	"syscall" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/sys/unix" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| ) | ||||
|  | ||||
| // GetCPUTime returns the how much CPU time has passed since the start of this process. | ||||
| func GetCPUTime() int64 { | ||||
| 	var ts unix.Timespec | ||||
| 	if err := unix.ClockGettime(unix.CLOCK_PROCESS_CPUTIME_ID, &ts); err != nil { | ||||
| 		grpclog.Fatal(err) | ||||
| 	} | ||||
| 	return ts.Nano() | ||||
| } | ||||
|  | ||||
| // Rusage is an alias for syscall.Rusage under linux non-appengine environment. | ||||
| type Rusage syscall.Rusage | ||||
|  | ||||
| // GetRusage returns the resource usage of current process. | ||||
| func GetRusage() (rusage *Rusage) { | ||||
| 	rusage = new(Rusage) | ||||
| 	syscall.Getrusage(syscall.RUSAGE_SELF, (*syscall.Rusage)(rusage)) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // CPUTimeDiff returns the differences of user CPU time and system CPU time used | ||||
| // between two Rusage structs. | ||||
| func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) { | ||||
| 	f := (*syscall.Rusage)(first) | ||||
| 	l := (*syscall.Rusage)(latest) | ||||
| 	var ( | ||||
| 		utimeDiffs  = l.Utime.Sec - f.Utime.Sec | ||||
| 		utimeDiffus = l.Utime.Usec - f.Utime.Usec | ||||
| 		stimeDiffs  = l.Stime.Sec - f.Stime.Sec | ||||
| 		stimeDiffus = l.Stime.Usec - f.Stime.Usec | ||||
| 	) | ||||
|  | ||||
| 	uTimeElapsed := float64(utimeDiffs) + float64(utimeDiffus)*1.0e-6 | ||||
| 	sTimeElapsed := float64(stimeDiffs) + float64(stimeDiffus)*1.0e-6 | ||||
|  | ||||
| 	return uTimeElapsed, sTimeElapsed | ||||
| } | ||||
|  | ||||
| // SetTCPUserTimeout sets the TCP user timeout on a connection's socket | ||||
| func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error { | ||||
| 	tcpconn, ok := conn.(*net.TCPConn) | ||||
| 	if !ok { | ||||
| 		// not a TCP connection. exit early | ||||
| 		return nil | ||||
| 	} | ||||
| 	rawConn, err := tcpconn.SyscallConn() | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("error getting raw connection: %v", err) | ||||
| 	} | ||||
| 	err = rawConn.Control(func(fd uintptr) { | ||||
| 		err = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT, int(timeout/time.Millisecond)) | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("error setting option on socket: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // GetTCPUserTimeout gets the TCP user timeout on a connection's socket | ||||
| func GetTCPUserTimeout(conn net.Conn) (opt int, err error) { | ||||
| 	tcpconn, ok := conn.(*net.TCPConn) | ||||
| 	if !ok { | ||||
| 		err = fmt.Errorf("conn is not *net.TCPConn. got %T", conn) | ||||
| 		return | ||||
| 	} | ||||
| 	rawConn, err := tcpconn.SyscallConn() | ||||
| 	if err != nil { | ||||
| 		err = fmt.Errorf("error getting raw connection: %v", err) | ||||
| 		return | ||||
| 	} | ||||
| 	err = rawConn.Control(func(fd uintptr) { | ||||
| 		opt, err = syscall.GetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT) | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		err = fmt.Errorf("error getting option on socket: %v", err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										63
									
								
								vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | ||||
| // +build !linux appengine | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 syscall | ||||
|  | ||||
| import ( | ||||
| 	"net" | ||||
| 	"time" | ||||
|  | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	grpclog.Info("CPU time info is unavailable on non-linux or appengine environment.") | ||||
| } | ||||
|  | ||||
| // GetCPUTime returns the how much CPU time has passed since the start of this process. | ||||
| // It always returns 0 under non-linux or appengine environment. | ||||
| func GetCPUTime() int64 { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| // Rusage is an empty struct under non-linux or appengine environment. | ||||
| type Rusage struct{} | ||||
|  | ||||
| // GetRusage is a no-op function under non-linux or appengine environment. | ||||
| func GetRusage() (rusage *Rusage) { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // CPUTimeDiff returns the differences of user CPU time and system CPU time used | ||||
| // between two Rusage structs. It a no-op function for non-linux or appengine environment. | ||||
| func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) { | ||||
| 	return 0, 0 | ||||
| } | ||||
|  | ||||
| // SetTCPUserTimeout is a no-op function under non-linux or appengine environments | ||||
| func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // GetTCPUserTimeout is a no-op function under non-linux or appengine environments | ||||
| // a negative return value indicates the operation is not supported | ||||
| func GetTCPUserTimeout(conn net.Conn) (int, error) { | ||||
| 	return -1, nil | ||||
| } | ||||
							
								
								
									
										7
									
								
								vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,9 +24,10 @@ import ( | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	// bdpLimit is the maximum value the flow control windows | ||||
| 	// will be increased to. | ||||
| 	bdpLimit = (1 << 20) * 4 | ||||
| 	// bdpLimit is the maximum value the flow control windows will be increased | ||||
| 	// to.  TCP typically limits this to 4MB, but some systems go up to 16MB. | ||||
| 	// Since this is only a limit, it is safe to make it optimistic. | ||||
| 	bdpLimit = (1 << 20) * 16 | ||||
| 	// alpha is a constant factor used to keep a moving average | ||||
| 	// of RTTs. | ||||
| 	alpha = 0.9 | ||||
|   | ||||
							
								
								
									
										52
									
								
								vendor/google.golang.org/grpc/internal/transport/go16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								vendor/google.golang.org/grpc/internal/transport/go16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,52 +0,0 @@ | ||||
| // +build go1.6,!go1.7 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2016 gRPC authors. | ||||
|  * | ||||
|  * 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 transport | ||||
|  | ||||
| import ( | ||||
| 	"net" | ||||
| 	"net/http" | ||||
|  | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/status" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| // dialContext connects to the address on the named network. | ||||
| func dialContext(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 	return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address) | ||||
| } | ||||
|  | ||||
| // ContextErr converts the error from context package into a status error. | ||||
| func ContextErr(err error) error { | ||||
| 	switch err { | ||||
| 	case context.DeadlineExceeded: | ||||
| 		return status.Error(codes.DeadlineExceeded, err.Error()) | ||||
| 	case context.Canceled: | ||||
| 		return status.Error(codes.Canceled, err.Error()) | ||||
| 	} | ||||
| 	return status.Errorf(codes.Internal, "Unexpected error from context packet: %v", err) | ||||
| } | ||||
|  | ||||
| // contextFromRequest returns a background context. | ||||
| func contextFromRequest(r *http.Request) context.Context { | ||||
| 	return context.Background() | ||||
| } | ||||
							
								
								
									
										53
									
								
								vendor/google.golang.org/grpc/internal/transport/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										53
									
								
								vendor/google.golang.org/grpc/internal/transport/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,53 +0,0 @@ | ||||
| // +build go1.7 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2016 gRPC authors. | ||||
|  * | ||||
|  * 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 transport | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"net" | ||||
| 	"net/http" | ||||
|  | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/status" | ||||
|  | ||||
| 	netctx "golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| // dialContext connects to the address on the named network. | ||||
| func dialContext(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 	return (&net.Dialer{}).DialContext(ctx, network, address) | ||||
| } | ||||
|  | ||||
| // ContextErr converts the error from context package into a status error. | ||||
| func ContextErr(err error) error { | ||||
| 	switch err { | ||||
| 	case context.DeadlineExceeded, netctx.DeadlineExceeded: | ||||
| 		return status.Error(codes.DeadlineExceeded, err.Error()) | ||||
| 	case context.Canceled, netctx.Canceled: | ||||
| 		return status.Error(codes.Canceled, err.Error()) | ||||
| 	} | ||||
| 	return status.Errorf(codes.Internal, "Unexpected error from context packet: %v", err) | ||||
| } | ||||
|  | ||||
| // contextFromRequest returns a context from the HTTP Request. | ||||
| func contextFromRequest(r *http.Request) context.Context { | ||||
| 	return r.Context() | ||||
| } | ||||
							
								
								
									
										4
									
								
								vendor/google.golang.org/grpc/internal/transport/handler_server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/google.golang.org/grpc/internal/transport/handler_server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,6 +24,7 @@ | ||||
| package transport | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| @@ -34,7 +35,6 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/golang/protobuf/proto" | ||||
| 	"golang.org/x/net/context" | ||||
| 	"golang.org/x/net/http2" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| @@ -307,7 +307,7 @@ func (ht *serverHandlerTransport) WriteHeader(s *Stream, md metadata.MD) error { | ||||
| func (ht *serverHandlerTransport) HandleStreams(startStream func(*Stream), traceCtx func(context.Context, string) context.Context) { | ||||
| 	// With this transport type there will be exactly 1 stream: this HTTP request. | ||||
|  | ||||
| 	ctx := contextFromRequest(ht.req) | ||||
| 	ctx := ht.req.Context() | ||||
| 	var cancel context.CancelFunc | ||||
| 	if ht.timeoutSet { | ||||
| 		ctx, cancel = context.WithTimeout(ctx, ht.timeout) | ||||
|   | ||||
							
								
								
									
										35
									
								
								vendor/google.golang.org/grpc/internal/transport/http2_client.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										35
									
								
								vendor/google.golang.org/grpc/internal/transport/http2_client.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,6 +19,8 @@ | ||||
| package transport | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"math" | ||||
| 	"net" | ||||
| @@ -28,13 +30,13 @@ import ( | ||||
| 	"sync/atomic" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"golang.org/x/net/http2" | ||||
| 	"golang.org/x/net/http2/hpack" | ||||
|  | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| 	"google.golang.org/grpc/internal/channelz" | ||||
| 	"google.golang.org/grpc/internal/syscall" | ||||
| 	"google.golang.org/grpc/keepalive" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
| 	"google.golang.org/grpc/peer" | ||||
| @@ -121,7 +123,7 @@ func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error | ||||
| 	if fn != nil { | ||||
| 		return fn(ctx, addr) | ||||
| 	} | ||||
| 	return dialContext(ctx, "tcp", addr) | ||||
| 	return (&net.Dialer{}).DialContext(ctx, "tcp", addr) | ||||
| } | ||||
|  | ||||
| func isTemporary(err error) bool { | ||||
| @@ -165,6 +167,21 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr TargetInfo, opts Conne | ||||
| 			conn.Close() | ||||
| 		} | ||||
| 	}(conn) | ||||
| 	kp := opts.KeepaliveParams | ||||
| 	// Validate keepalive parameters. | ||||
| 	if kp.Time == 0 { | ||||
| 		kp.Time = defaultClientKeepaliveTime | ||||
| 	} | ||||
| 	if kp.Timeout == 0 { | ||||
| 		kp.Timeout = defaultClientKeepaliveTimeout | ||||
| 	} | ||||
| 	keepaliveEnabled := false | ||||
| 	if kp.Time != infinity { | ||||
| 		if err = syscall.SetTCPUserTimeout(conn, kp.Timeout); err != nil { | ||||
| 			return nil, connectionErrorf(false, err, "transport: failed to set TCP_USER_TIMEOUT: %v", err) | ||||
| 		} | ||||
| 		keepaliveEnabled = true | ||||
| 	} | ||||
| 	var ( | ||||
| 		isSecure bool | ||||
| 		authInfo credentials.AuthInfo | ||||
| @@ -188,14 +205,6 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr TargetInfo, opts Conne | ||||
| 		} | ||||
| 		isSecure = true | ||||
| 	} | ||||
| 	kp := opts.KeepaliveParams | ||||
| 	// Validate keepalive parameters. | ||||
| 	if kp.Time == 0 { | ||||
| 		kp.Time = defaultClientKeepaliveTime | ||||
| 	} | ||||
| 	if kp.Timeout == 0 { | ||||
| 		kp.Timeout = defaultClientKeepaliveTimeout | ||||
| 	} | ||||
| 	dynamicWindow := true | ||||
| 	icwz := int32(initialWindowSize) | ||||
| 	if opts.InitialConnWindowSize >= defaultWindowSize { | ||||
| @@ -239,6 +248,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr TargetInfo, opts Conne | ||||
| 		czData:                new(channelzData), | ||||
| 		onGoAway:              onGoAway, | ||||
| 		onClose:               onClose, | ||||
| 		keepaliveEnabled:      keepaliveEnabled, | ||||
| 	} | ||||
| 	t.controlBuf = newControlBuffer(t.ctxDone) | ||||
| 	if opts.InitialWindowSize >= defaultWindowSize { | ||||
| @@ -265,10 +275,9 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr TargetInfo, opts Conne | ||||
| 		t.statsHandler.HandleConn(t.ctx, connBegin) | ||||
| 	} | ||||
| 	if channelz.IsOn() { | ||||
| 		t.channelzID = channelz.RegisterNormalSocket(t, opts.ChannelzParentID, "") | ||||
| 		t.channelzID = channelz.RegisterNormalSocket(t, opts.ChannelzParentID, fmt.Sprintf("%s -> %s", t.localAddr, t.remoteAddr)) | ||||
| 	} | ||||
| 	if t.kp.Time != infinity { | ||||
| 		t.keepaliveEnabled = true | ||||
| 	if t.keepaliveEnabled { | ||||
| 		go t.keepalive() | ||||
| 	} | ||||
| 	// Start the reader goroutine for incoming message. Each transport has | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/google.golang.org/grpc/internal/transport/http2_server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/google.golang.org/grpc/internal/transport/http2_server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,6 +20,7 @@ package transport | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| @@ -31,7 +32,6 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/golang/protobuf/proto" | ||||
| 	"golang.org/x/net/context" | ||||
| 	"golang.org/x/net/http2" | ||||
| 	"golang.org/x/net/http2/hpack" | ||||
|  | ||||
| @@ -237,7 +237,7 @@ func newHTTP2Server(conn net.Conn, config *ServerConfig) (_ ServerTransport, err | ||||
| 		t.stats.HandleConn(t.ctx, connBegin) | ||||
| 	} | ||||
| 	if channelz.IsOn() { | ||||
| 		t.channelzID = channelz.RegisterNormalSocket(t, config.ChannelzParentID, "") | ||||
| 		t.channelzID = channelz.RegisterNormalSocket(t, config.ChannelzParentID, fmt.Sprintf("%s -> %s", t.remoteAddr, t.localAddr)) | ||||
| 	} | ||||
| 	t.framer.writer.Flush() | ||||
|  | ||||
|   | ||||
							
								
								
									
										34
									
								
								vendor/google.golang.org/grpc/internal/transport/transport.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								vendor/google.golang.org/grpc/internal/transport/transport.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -22,6 +22,7 @@ | ||||
| package transport | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| @@ -29,7 +30,6 @@ import ( | ||||
| 	"sync" | ||||
| 	"sync/atomic" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| 	"google.golang.org/grpc/keepalive" | ||||
| @@ -187,7 +187,11 @@ type Stream struct { | ||||
|  | ||||
| 	// hdrMu protects header and trailer metadata on the server-side. | ||||
| 	hdrMu sync.Mutex | ||||
| 	header  metadata.MD // the received header metadata. | ||||
| 	// On client side, header keeps the received header metadata. | ||||
| 	// | ||||
| 	// On server side, header keeps the header set by SetHeader(). The complete | ||||
| 	// header will merged into this after t.WriteHeader() is called. | ||||
| 	header  metadata.MD | ||||
| 	trailer metadata.MD // the key-value map of trailer metadata. | ||||
|  | ||||
| 	noHeaders bool // set if the client never received headers (set only after the stream is done). | ||||
| @@ -266,10 +270,19 @@ func (s *Stream) Done() <-chan struct{} { | ||||
| 	return s.done | ||||
| } | ||||
|  | ||||
| // Header acquires the key-value pairs of header metadata once it | ||||
| // is available. It blocks until i) the metadata is ready or ii) there is no | ||||
| // header metadata or iii) the stream is canceled/expired. | ||||
| // Header returns the header metadata of the stream. | ||||
| // | ||||
| // On client side, it acquires the key-value pairs of header metadata once it is | ||||
| // available. It blocks until i) the metadata is ready or ii) there is no header | ||||
| // metadata or iii) the stream is canceled/expired. | ||||
| // | ||||
| // On server side, it returns the out header after t.WriteHeader is called. | ||||
| func (s *Stream) Header() (metadata.MD, error) { | ||||
| 	if s.headerChan == nil && s.header != nil { | ||||
| 		// On server side, return the header in stream. It will be the out | ||||
| 		// header after t.WriteHeader is called. | ||||
| 		return s.header.Copy(), nil | ||||
| 	} | ||||
| 	err := s.waitOnHeader() | ||||
| 	// Even if the stream is closed, header is returned if available. | ||||
| 	select { | ||||
| @@ -710,3 +723,14 @@ type channelzData struct { | ||||
| 	lastMsgSentTime       int64 | ||||
| 	lastMsgRecvTime       int64 | ||||
| } | ||||
|  | ||||
| // ContextErr converts the error from context package into a status error. | ||||
| func ContextErr(err error) error { | ||||
| 	switch err { | ||||
| 	case context.DeadlineExceeded: | ||||
| 		return status.Error(codes.DeadlineExceeded, err.Error()) | ||||
| 	case context.Canceled: | ||||
| 		return status.Error(codes.Canceled, err.Error()) | ||||
| 	} | ||||
| 	return status.Errorf(codes.Internal, "Unexpected error from context packet: %v", err) | ||||
| } | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/google.golang.org/grpc/metadata/metadata.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/google.golang.org/grpc/metadata/metadata.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -22,10 +22,9 @@ | ||||
| package metadata // import "google.golang.org/grpc/metadata" | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| // DecodeKeyValue returns k, v, nil. | ||||
|   | ||||
							
								
								
									
										5
									
								
								vendor/google.golang.org/grpc/naming/dns_resolver.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/google.golang.org/grpc/naming/dns_resolver.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,13 +19,13 @@ | ||||
| package naming | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"net" | ||||
| 	"strconv" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| ) | ||||
|  | ||||
| @@ -37,6 +37,9 @@ const ( | ||||
| var ( | ||||
| 	errMissingAddr  = errors.New("missing address") | ||||
| 	errWatcherClose = errors.New("watcher has been closed") | ||||
|  | ||||
| 	lookupHost = net.DefaultResolver.LookupHost | ||||
| 	lookupSRV  = net.DefaultResolver.LookupSRV | ||||
| ) | ||||
|  | ||||
| // NewDNSResolverWithFreq creates a DNS Resolver that can resolve DNS names, and | ||||
|   | ||||
							
								
								
									
										34
									
								
								vendor/google.golang.org/grpc/naming/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								vendor/google.golang.org/grpc/naming/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,34 +0,0 @@ | ||||
| // +build go1.6,!go1.8 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2017 gRPC authors. | ||||
|  * | ||||
|  * 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 naming | ||||
|  | ||||
| import ( | ||||
| 	"net" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	lookupHost = func(ctx context.Context, host string) ([]string, error) { return net.LookupHost(host) } | ||||
| 	lookupSRV  = func(ctx context.Context, service, proto, name string) (string, []*net.SRV, error) { | ||||
| 		return net.LookupSRV(service, proto, name) | ||||
| 	} | ||||
| ) | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/peer/peer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/peer/peer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,9 +21,9 @@ | ||||
| package peer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"net" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| ) | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/picker_wrapper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/picker_wrapper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,10 +19,10 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"io" | ||||
| 	"sync" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/google.golang.org/grpc/pickfirst.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/google.golang.org/grpc/pickfirst.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,7 +19,8 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/net/context" | ||||
| 	"context" | ||||
|  | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	"google.golang.org/grpc/connectivity" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
|   | ||||
							
								
								
									
										52
									
								
								vendor/google.golang.org/grpc/proxy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								vendor/google.golang.org/grpc/proxy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,6 +20,8 @@ package grpc | ||||
|  | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"context" | ||||
| 	"encoding/base64" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| @@ -27,10 +29,10 @@ import ( | ||||
| 	"net/http" | ||||
| 	"net/http/httputil" | ||||
| 	"net/url" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| const proxyAuthHeaderKey = "Proxy-Authorization" | ||||
|  | ||||
| var ( | ||||
| 	// errDisabled indicates that proxy is disabled for the address. | ||||
| 	errDisabled = errors.New("proxy is disabled for the address") | ||||
| @@ -38,7 +40,7 @@ var ( | ||||
| 	httpProxyFromEnvironment = http.ProxyFromEnvironment | ||||
| ) | ||||
|  | ||||
| func mapAddress(ctx context.Context, address string) (string, error) { | ||||
| func mapAddress(ctx context.Context, address string) (*url.URL, error) { | ||||
| 	req := &http.Request{ | ||||
| 		URL: &url.URL{ | ||||
| 			Scheme: "https", | ||||
| @@ -47,12 +49,12 @@ func mapAddress(ctx context.Context, address string) (string, error) { | ||||
| 	} | ||||
| 	url, err := httpProxyFromEnvironment(req) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if url == nil { | ||||
| 		return "", errDisabled | ||||
| 		return nil, errDisabled | ||||
| 	} | ||||
| 	return url.Host, nil | ||||
| 	return url, nil | ||||
| } | ||||
|  | ||||
| // To read a response from a net.Conn, http.ReadResponse() takes a bufio.Reader. | ||||
| @@ -69,18 +71,28 @@ func (c *bufConn) Read(b []byte) (int, error) { | ||||
| 	return c.r.Read(b) | ||||
| } | ||||
|  | ||||
| func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, addr string) (_ net.Conn, err error) { | ||||
| func basicAuth(username, password string) string { | ||||
| 	auth := username + ":" + password | ||||
| 	return base64.StdEncoding.EncodeToString([]byte(auth)) | ||||
| } | ||||
|  | ||||
| func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, backendAddr string, proxyURL *url.URL) (_ net.Conn, err error) { | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			conn.Close() | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	req := (&http.Request{ | ||||
| 	req := &http.Request{ | ||||
| 		Method: http.MethodConnect, | ||||
| 		URL:    &url.URL{Host: addr}, | ||||
| 		URL:    &url.URL{Host: backendAddr}, | ||||
| 		Header: map[string][]string{"User-Agent": {grpcUA}}, | ||||
| 	}) | ||||
| 	} | ||||
| 	if t := proxyURL.User; t != nil { | ||||
| 		u := t.Username() | ||||
| 		p, _ := t.Password() | ||||
| 		req.Header.Add(proxyAuthHeaderKey, "Basic "+basicAuth(u, p)) | ||||
| 	} | ||||
|  | ||||
| 	if err := sendHTTPRequest(ctx, req, conn); err != nil { | ||||
| 		return nil, fmt.Errorf("failed to write the HTTP request: %v", err) | ||||
| @@ -108,23 +120,33 @@ func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, addr string) (_ | ||||
| // provided dialer, does HTTP CONNECT handshake and returns the connection. | ||||
| func newProxyDialer(dialer func(context.Context, string) (net.Conn, error)) func(context.Context, string) (net.Conn, error) { | ||||
| 	return func(ctx context.Context, addr string) (conn net.Conn, err error) { | ||||
| 		var skipHandshake bool | ||||
| 		newAddr, err := mapAddress(ctx, addr) | ||||
| 		var newAddr string | ||||
| 		proxyURL, err := mapAddress(ctx, addr) | ||||
| 		if err != nil { | ||||
| 			if err != errDisabled { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			skipHandshake = true | ||||
| 			newAddr = addr | ||||
| 		} else { | ||||
| 			newAddr = proxyURL.Host | ||||
| 		} | ||||
|  | ||||
| 		conn, err = dialer(ctx, newAddr) | ||||
| 		if err != nil { | ||||
| 			return | ||||
| 		} | ||||
| 		if !skipHandshake { | ||||
| 			conn, err = doHTTPConnectHandshake(ctx, conn, addr) | ||||
| 		if proxyURL != nil { | ||||
| 			// proxy is disabled if proxyURL is nil. | ||||
| 			conn, err = doHTTPConnectHandshake(ctx, conn, addr, proxyURL) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error { | ||||
| 	req = req.WithContext(ctx) | ||||
| 	if err := req.Write(conn); err != nil { | ||||
| 		return fmt.Errorf("failed to write the HTTP request: %v", err) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										28
									
								
								vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,6 +21,7 @@ | ||||
| package dns | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| @@ -31,7 +32,6 @@ import ( | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| 	"google.golang.org/grpc/internal/backoff" | ||||
| 	"google.golang.org/grpc/internal/grpcrand" | ||||
| @@ -45,6 +45,7 @@ func init() { | ||||
| const ( | ||||
| 	defaultPort       = "443" | ||||
| 	defaultFreq       = time.Minute * 30 | ||||
| 	defaultDNSSvrPort = "53" | ||||
| 	golang            = "GO" | ||||
| 	// In DNS, service config is encoded in a TXT record via the mechanism | ||||
| 	// described in RFC-1464 using the attribute name grpc_config. | ||||
| @@ -61,6 +62,31 @@ var ( | ||||
| 	errEndsWithColon = errors.New("dns resolver: missing port after port-separator colon") | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	defaultResolver netResolver = net.DefaultResolver | ||||
| ) | ||||
|  | ||||
| var customAuthorityDialler = func(authority string) func(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 	return func(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 		var dialer net.Dialer | ||||
| 		return dialer.DialContext(ctx, network, authority) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| var customAuthorityResolver = func(authority string) (netResolver, error) { | ||||
| 	host, port, err := parseTarget(authority, defaultDNSSvrPort) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	authorityWithPort := net.JoinHostPort(host, port) | ||||
|  | ||||
| 	return &net.Resolver{ | ||||
| 		PreferGo: true, | ||||
| 		Dial:     customAuthorityDialler(authorityWithPort), | ||||
| 	}, nil | ||||
| } | ||||
|  | ||||
| // NewBuilder creates a dnsBuilder which is used to factory DNS resolvers. | ||||
| func NewBuilder() resolver.Builder { | ||||
| 	return &dnsBuilder{minFreq: defaultFreq} | ||||
|   | ||||
							
								
								
									
										54
									
								
								vendor/google.golang.org/grpc/resolver/dns/go19.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										54
									
								
								vendor/google.golang.org/grpc/resolver/dns/go19.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,54 +0,0 @@ | ||||
| // +build go1.9 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 dns | ||||
|  | ||||
| import ( | ||||
| 	"net" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	defaultResolver netResolver = net.DefaultResolver | ||||
| ) | ||||
|  | ||||
| const defaultDNSSvrPort = "53" | ||||
|  | ||||
| var customAuthorityDialler = func(authority string) func(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 	return func(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 		var dialer net.Dialer | ||||
| 		return dialer.DialContext(ctx, network, authority) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| var customAuthorityResolver = func(authority string) (netResolver, error) { | ||||
| 	host, port, err := parseTarget(authority, defaultDNSSvrPort) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	authorityWithPort := net.JoinHostPort(host, port) | ||||
|  | ||||
| 	return &net.Resolver{ | ||||
| 		PreferGo: true, | ||||
| 		Dial:     customAuthorityDialler(authorityWithPort), | ||||
| 	}, nil | ||||
| } | ||||
							
								
								
									
										51
									
								
								vendor/google.golang.org/grpc/resolver/dns/pre_go19.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								vendor/google.golang.org/grpc/resolver/dns/pre_go19.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,51 +0,0 @@ | ||||
| // +build go1.6, !go1.9 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 dns | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	defaultResolver netResolver = &preGo19Resolver{} | ||||
| ) | ||||
|  | ||||
| type preGo19Resolver struct { | ||||
| } | ||||
|  | ||||
| func (*preGo19Resolver) LookupHost(ctx context.Context, host string) ([]string, error) { | ||||
| 	return net.LookupHost(host) | ||||
| } | ||||
|  | ||||
| func (*preGo19Resolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*net.SRV, error) { | ||||
| 	return net.LookupSRV(service, proto, name) | ||||
| } | ||||
|  | ||||
| func (*preGo19Resolver) LookupTXT(ctx context.Context, name string) ([]string, error) { | ||||
| 	return net.LookupTXT(name) | ||||
| } | ||||
|  | ||||
| var customAuthorityResolver = func(authority string) (netResolver, error) { | ||||
| 	return nil, fmt.Errorf("Default DNS resolver does not support custom DNS server with go < 1.9") | ||||
| } | ||||
							
								
								
									
										56
									
								
								vendor/google.golang.org/grpc/resolver_conn_wrapper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										56
									
								
								vendor/google.golang.org/grpc/resolver_conn_wrapper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -93,47 +93,6 @@ func newCCResolverWrapper(cc *ClientConn) (*ccResolverWrapper, error) { | ||||
| 	return ccr, nil | ||||
| } | ||||
|  | ||||
| func (ccr *ccResolverWrapper) start() { | ||||
| 	go ccr.watcher() | ||||
| } | ||||
|  | ||||
| // watcher processes address updates and service config updates sequentially. | ||||
| // Otherwise, we need to resolve possible races between address and service | ||||
| // config (e.g. they specify different balancer types). | ||||
| func (ccr *ccResolverWrapper) watcher() { | ||||
| 	for { | ||||
| 		select { | ||||
| 		case <-ccr.done: | ||||
| 			return | ||||
| 		default: | ||||
| 		} | ||||
|  | ||||
| 		select { | ||||
| 		case addrs := <-ccr.addrCh: | ||||
| 			select { | ||||
| 			case <-ccr.done: | ||||
| 				return | ||||
| 			default: | ||||
| 			} | ||||
| 			grpclog.Infof("ccResolverWrapper: sending new addresses to cc: %v", addrs) | ||||
| 			if channelz.IsOn() { | ||||
| 				ccr.addChannelzTraceEvent(addrs) | ||||
| 			} | ||||
| 			ccr.cc.handleResolvedAddrs(addrs, nil) | ||||
| 		case sc := <-ccr.scCh: | ||||
| 			select { | ||||
| 			case <-ccr.done: | ||||
| 				return | ||||
| 			default: | ||||
| 			} | ||||
| 			grpclog.Infof("ccResolverWrapper: got new service config: %v", sc) | ||||
| 			ccr.cc.handleServiceConfig(sc) | ||||
| 		case <-ccr.done: | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (ccr *ccResolverWrapper) resolveNow(o resolver.ResolveNowOption) { | ||||
| 	ccr.resolver.ResolveNow(o) | ||||
| } | ||||
| @@ -146,20 +105,27 @@ func (ccr *ccResolverWrapper) close() { | ||||
| // NewAddress is called by the resolver implemenetion to send addresses to gRPC. | ||||
| func (ccr *ccResolverWrapper) NewAddress(addrs []resolver.Address) { | ||||
| 	select { | ||||
| 	case <-ccr.addrCh: | ||||
| 	case <-ccr.done: | ||||
| 		return | ||||
| 	default: | ||||
| 	} | ||||
| 	ccr.addrCh <- addrs | ||||
| 	grpclog.Infof("ccResolverWrapper: sending new addresses to cc: %v", addrs) | ||||
| 	if channelz.IsOn() { | ||||
| 		ccr.addChannelzTraceEvent(addrs) | ||||
| 	} | ||||
| 	ccr.cc.handleResolvedAddrs(addrs, nil) | ||||
| } | ||||
|  | ||||
| // NewServiceConfig is called by the resolver implemenetion to send service | ||||
| // configs to gRPC. | ||||
| func (ccr *ccResolverWrapper) NewServiceConfig(sc string) { | ||||
| 	select { | ||||
| 	case <-ccr.scCh: | ||||
| 	case <-ccr.done: | ||||
| 		return | ||||
| 	default: | ||||
| 	} | ||||
| 	ccr.scCh <- sc | ||||
| 	grpclog.Infof("ccResolverWrapper: got new service config: %v", sc) | ||||
| 	ccr.cc.handleServiceConfig(sc) | ||||
| } | ||||
|  | ||||
| func (ccr *ccResolverWrapper) addChannelzTraceEvent(addrs []resolver.Address) { | ||||
|   | ||||
							
								
								
									
										52
									
								
								vendor/google.golang.org/grpc/rpc_util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								vendor/google.golang.org/grpc/rpc_util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,6 +21,7 @@ package grpc | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"compress/gzip" | ||||
| 	"context" | ||||
| 	"encoding/binary" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| @@ -31,7 +32,6 @@ import ( | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/credentials" | ||||
| 	"google.golang.org/grpc/encoding" | ||||
| @@ -155,7 +155,7 @@ func (d *gzipDecompressor) Type() string { | ||||
| type callInfo struct { | ||||
| 	compressorType        string | ||||
| 	failFast              bool | ||||
| 	stream                *clientStream | ||||
| 	stream                ClientStream | ||||
| 	maxReceiveMessageSize *int | ||||
| 	maxSendMessageSize    *int | ||||
| 	creds                 credentials.PerRPCCredentials | ||||
| @@ -598,13 +598,18 @@ func checkRecvPayload(pf payloadFormat, recvCompress string, haveCompressor bool | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func recvAndDecompress(p *parser, s *transport.Stream, dc Decompressor, maxReceiveMessageSize int, inPayload *stats.InPayload, compressor encoding.Compressor) ([]byte, error) { | ||||
| type payloadInfo struct { | ||||
| 	wireLength        int // The compressed length got from wire. | ||||
| 	uncompressedBytes []byte | ||||
| } | ||||
|  | ||||
| func recvAndDecompress(p *parser, s *transport.Stream, dc Decompressor, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor) ([]byte, error) { | ||||
| 	pf, d, err := p.recvMsg(maxReceiveMessageSize) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if inPayload != nil { | ||||
| 		inPayload.WireLength = len(d) | ||||
| 	if payInfo != nil { | ||||
| 		payInfo.wireLength = len(d) | ||||
| 	} | ||||
|  | ||||
| 	if st := checkRecvPayload(pf, s.RecvCompress(), compressor != nil || dc != nil); st != nil { | ||||
| @@ -641,20 +646,16 @@ func recvAndDecompress(p *parser, s *transport.Stream, dc Decompressor, maxRecei | ||||
| // For the two compressor parameters, both should not be set, but if they are, | ||||
| // dc takes precedence over compressor. | ||||
| // TODO(dfawley): wrap the old compressor/decompressor using the new API? | ||||
| func recv(p *parser, c baseCodec, s *transport.Stream, dc Decompressor, m interface{}, maxReceiveMessageSize int, inPayload *stats.InPayload, compressor encoding.Compressor) error { | ||||
| 	d, err := recvAndDecompress(p, s, dc, maxReceiveMessageSize, inPayload, compressor) | ||||
| func recv(p *parser, c baseCodec, s *transport.Stream, dc Decompressor, m interface{}, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor) error { | ||||
| 	d, err := recvAndDecompress(p, s, dc, maxReceiveMessageSize, payInfo, compressor) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if err := c.Unmarshal(d, m); err != nil { | ||||
| 		return status.Errorf(codes.Internal, "grpc: failed to unmarshal the received message %v", err) | ||||
| 	} | ||||
| 	if inPayload != nil { | ||||
| 		inPayload.RecvTime = time.Now() | ||||
| 		inPayload.Payload = m | ||||
| 		// TODO truncate large payload. | ||||
| 		inPayload.Data = d | ||||
| 		inPayload.Length = len(d) | ||||
| 	if payInfo != nil { | ||||
| 		payInfo.uncompressedBytes = d | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| @@ -704,6 +705,31 @@ func Errorf(c codes.Code, format string, a ...interface{}) error { | ||||
| 	return status.Errorf(c, format, a...) | ||||
| } | ||||
|  | ||||
| // toRPCErr converts an error into an error from the status package. | ||||
| func toRPCErr(err error) error { | ||||
| 	if err == nil || err == io.EOF { | ||||
| 		return err | ||||
| 	} | ||||
| 	if err == io.ErrUnexpectedEOF { | ||||
| 		return status.Error(codes.Internal, err.Error()) | ||||
| 	} | ||||
| 	if _, ok := status.FromError(err); ok { | ||||
| 		return err | ||||
| 	} | ||||
| 	switch e := err.(type) { | ||||
| 	case transport.ConnectionError: | ||||
| 		return status.Error(codes.Unavailable, e.Desc) | ||||
| 	default: | ||||
| 		switch err { | ||||
| 		case context.DeadlineExceeded: | ||||
| 			return status.Error(codes.DeadlineExceeded, err.Error()) | ||||
| 		case context.Canceled: | ||||
| 			return status.Error(codes.Canceled, err.Error()) | ||||
| 		} | ||||
| 	} | ||||
| 	return status.Error(codes.Unknown, err.Error()) | ||||
| } | ||||
|  | ||||
| // setCallInfoCodec should only be called after CallOptions have been applied. | ||||
| func setCallInfoCodec(c *callInfo) error { | ||||
| 	if c.codec != nil { | ||||
|   | ||||
							
								
								
									
										136
									
								
								vendor/google.golang.org/grpc/server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										136
									
								
								vendor/google.golang.org/grpc/server.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,6 +19,7 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| @@ -32,7 +33,6 @@ import ( | ||||
| 	"sync/atomic" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"golang.org/x/net/trace" | ||||
|  | ||||
| 	"google.golang.org/grpc/codes" | ||||
| @@ -40,10 +40,12 @@ import ( | ||||
| 	"google.golang.org/grpc/encoding" | ||||
| 	"google.golang.org/grpc/encoding/proto" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| 	"google.golang.org/grpc/internal/binarylog" | ||||
| 	"google.golang.org/grpc/internal/channelz" | ||||
| 	"google.golang.org/grpc/internal/transport" | ||||
| 	"google.golang.org/grpc/keepalive" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
| 	"google.golang.org/grpc/peer" | ||||
| 	"google.golang.org/grpc/stats" | ||||
| 	"google.golang.org/grpc/status" | ||||
| 	"google.golang.org/grpc/tap" | ||||
| @@ -535,7 +537,7 @@ func (s *Server) Serve(lis net.Listener) error { | ||||
| 	s.lis[ls] = true | ||||
|  | ||||
| 	if channelz.IsOn() { | ||||
| 		ls.channelzID = channelz.RegisterListenSocket(ls, s.channelzID, "") | ||||
| 		ls.channelzID = channelz.RegisterListenSocket(ls, s.channelzID, lis.Addr().String()) | ||||
| 	} | ||||
| 	s.mu.Unlock() | ||||
|  | ||||
| @@ -862,6 +864,30 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport. | ||||
| 		}() | ||||
| 	} | ||||
|  | ||||
| 	binlog := binarylog.GetMethodLogger(stream.Method()) | ||||
| 	if binlog != nil { | ||||
| 		ctx := stream.Context() | ||||
| 		md, _ := metadata.FromIncomingContext(ctx) | ||||
| 		logEntry := &binarylog.ClientHeader{ | ||||
| 			Header:     md, | ||||
| 			MethodName: stream.Method(), | ||||
| 			PeerAddr:   nil, | ||||
| 		} | ||||
| 		if deadline, ok := ctx.Deadline(); ok { | ||||
| 			logEntry.Timeout = deadline.Sub(time.Now()) | ||||
| 			if logEntry.Timeout < 0 { | ||||
| 				logEntry.Timeout = 0 | ||||
| 			} | ||||
| 		} | ||||
| 		if a := md[":authority"]; len(a) > 0 { | ||||
| 			logEntry.Authority = a[0] | ||||
| 		} | ||||
| 		if peer, ok := peer.FromContext(ctx); ok { | ||||
| 			logEntry.PeerAddr = peer.Addr | ||||
| 		} | ||||
| 		binlog.Log(logEntry) | ||||
| 	} | ||||
|  | ||||
| 	// comp and cp are used for compression.  decomp and dc are used for | ||||
| 	// decompression.  If comp and decomp are both set, they are the same; | ||||
| 	// however they are kept separate to ensure that at most one of the | ||||
| @@ -898,13 +924,11 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport. | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	var inPayload *stats.InPayload | ||||
| 	if sh != nil { | ||||
| 		inPayload = &stats.InPayload{ | ||||
| 			RecvTime: time.Now(), | ||||
| 	var payInfo *payloadInfo | ||||
| 	if sh != nil || binlog != nil { | ||||
| 		payInfo = &payloadInfo{} | ||||
| 	} | ||||
| 	} | ||||
| 	d, err := recvAndDecompress(&parser{r: stream}, stream, dc, s.opts.maxReceiveMessageSize, inPayload, decomp) | ||||
| 	d, err := recvAndDecompress(&parser{r: stream}, stream, dc, s.opts.maxReceiveMessageSize, payInfo, decomp) | ||||
| 	if err != nil { | ||||
| 		if st, ok := status.FromError(err); ok { | ||||
| 			if e := t.WriteStatus(stream, st); e != nil { | ||||
| @@ -920,11 +944,18 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport. | ||||
| 		if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil { | ||||
| 			return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err) | ||||
| 		} | ||||
| 		if inPayload != nil { | ||||
| 			inPayload.Payload = v | ||||
| 			inPayload.Data = d | ||||
| 			inPayload.Length = len(d) | ||||
| 			sh.HandleRPC(stream.Context(), inPayload) | ||||
| 		if sh != nil { | ||||
| 			sh.HandleRPC(stream.Context(), &stats.InPayload{ | ||||
| 				RecvTime: time.Now(), | ||||
| 				Payload:  v, | ||||
| 				Data:     d, | ||||
| 				Length:   len(d), | ||||
| 			}) | ||||
| 		} | ||||
| 		if binlog != nil { | ||||
| 			binlog.Log(&binarylog.ClientMessage{ | ||||
| 				Message: d, | ||||
| 			}) | ||||
| 		} | ||||
| 		if trInfo != nil { | ||||
| 			trInfo.tr.LazyLog(&payload{sent: false, msg: v}, true) | ||||
| @@ -947,6 +978,19 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport. | ||||
| 		if e := t.WriteStatus(stream, appStatus); e != nil { | ||||
| 			grpclog.Warningf("grpc: Server.processUnaryRPC failed to write status: %v", e) | ||||
| 		} | ||||
| 		if binlog != nil { | ||||
| 			if h, _ := stream.Header(); h.Len() > 0 { | ||||
| 				// Only log serverHeader if there was header. Otherwise it can | ||||
| 				// be trailer only. | ||||
| 				binlog.Log(&binarylog.ServerHeader{ | ||||
| 					Header: h, | ||||
| 				}) | ||||
| 			} | ||||
| 			binlog.Log(&binarylog.ServerTrailer{ | ||||
| 				Trailer: stream.Trailer(), | ||||
| 				Err:     appErr, | ||||
| 			}) | ||||
| 		} | ||||
| 		return appErr | ||||
| 	} | ||||
| 	if trInfo != nil { | ||||
| @@ -971,8 +1015,27 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport. | ||||
| 				panic(fmt.Sprintf("grpc: Unexpected error (%T) from sendResponse: %v", st, st)) | ||||
| 			} | ||||
| 		} | ||||
| 		if binlog != nil { | ||||
| 			h, _ := stream.Header() | ||||
| 			binlog.Log(&binarylog.ServerHeader{ | ||||
| 				Header: h, | ||||
| 			}) | ||||
| 			binlog.Log(&binarylog.ServerTrailer{ | ||||
| 				Trailer: stream.Trailer(), | ||||
| 				Err:     appErr, | ||||
| 			}) | ||||
| 		} | ||||
| 		return err | ||||
| 	} | ||||
| 	if binlog != nil { | ||||
| 		h, _ := stream.Header() | ||||
| 		binlog.Log(&binarylog.ServerHeader{ | ||||
| 			Header: h, | ||||
| 		}) | ||||
| 		binlog.Log(&binarylog.ServerMessage{ | ||||
| 			Message: reply, | ||||
| 		}) | ||||
| 	} | ||||
| 	if channelz.IsOn() { | ||||
| 		t.IncrMsgSent() | ||||
| 	} | ||||
| @@ -982,7 +1045,14 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport. | ||||
| 	// TODO: Should we be logging if writing status failed here, like above? | ||||
| 	// Should the logging be in WriteStatus?  Should we ignore the WriteStatus | ||||
| 	// error or allow the stats handler to see it? | ||||
| 	return t.WriteStatus(stream, status.New(codes.OK, "")) | ||||
| 	err = t.WriteStatus(stream, status.New(codes.OK, "")) | ||||
| 	if binlog != nil { | ||||
| 		binlog.Log(&binarylog.ServerTrailer{ | ||||
| 			Trailer: stream.Trailer(), | ||||
| 			Err:     appErr, | ||||
| 		}) | ||||
| 	} | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, sd *StreamDesc, trInfo *traceInfo) (err error) { | ||||
| @@ -1027,6 +1097,29 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp | ||||
| 		statsHandler:          sh, | ||||
| 	} | ||||
|  | ||||
| 	ss.binlog = binarylog.GetMethodLogger(stream.Method()) | ||||
| 	if ss.binlog != nil { | ||||
| 		md, _ := metadata.FromIncomingContext(ctx) | ||||
| 		logEntry := &binarylog.ClientHeader{ | ||||
| 			Header:     md, | ||||
| 			MethodName: stream.Method(), | ||||
| 			PeerAddr:   nil, | ||||
| 		} | ||||
| 		if deadline, ok := ctx.Deadline(); ok { | ||||
| 			logEntry.Timeout = deadline.Sub(time.Now()) | ||||
| 			if logEntry.Timeout < 0 { | ||||
| 				logEntry.Timeout = 0 | ||||
| 			} | ||||
| 		} | ||||
| 		if a := md[":authority"]; len(a) > 0 { | ||||
| 			logEntry.Authority = a[0] | ||||
| 		} | ||||
| 		if peer, ok := peer.FromContext(ss.Context()); ok { | ||||
| 			logEntry.PeerAddr = peer.Addr | ||||
| 		} | ||||
| 		ss.binlog.Log(logEntry) | ||||
| 	} | ||||
|  | ||||
| 	// If dc is set and matches the stream's compression, use it.  Otherwise, try | ||||
| 	// to find a matching registered compressor for decomp. | ||||
| 	if rc := stream.RecvCompress(); s.opts.dc != nil && s.opts.dc.Type() == rc { | ||||
| @@ -1096,6 +1189,12 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp | ||||
| 			ss.mu.Unlock() | ||||
| 		} | ||||
| 		t.WriteStatus(ss.s, appStatus) | ||||
| 		if ss.binlog != nil { | ||||
| 			ss.binlog.Log(&binarylog.ServerTrailer{ | ||||
| 				Trailer: ss.s.Trailer(), | ||||
| 				Err:     appErr, | ||||
| 			}) | ||||
| 		} | ||||
| 		// TODO: Should we log an error from WriteStatus here and below? | ||||
| 		return appErr | ||||
| 	} | ||||
| @@ -1104,7 +1203,14 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp | ||||
| 		ss.trInfo.tr.LazyLog(stringer("OK"), false) | ||||
| 		ss.mu.Unlock() | ||||
| 	} | ||||
| 	return t.WriteStatus(ss.s, status.New(codes.OK, "")) | ||||
| 	err = t.WriteStatus(ss.s, status.New(codes.OK, "")) | ||||
| 	if ss.binlog != nil { | ||||
| 		ss.binlog.Log(&binarylog.ServerTrailer{ | ||||
| 			Trailer: ss.s.Trailer(), | ||||
| 			Err:     appErr, | ||||
| 		}) | ||||
| 	} | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Stream, trInfo *traceInfo) { | ||||
|   | ||||
							
								
								
									
										11
									
								
								vendor/google.golang.org/grpc/service_config.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								vendor/google.golang.org/grpc/service_config.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -96,6 +96,15 @@ type ServiceConfig struct { | ||||
| 	// If token_count is less than or equal to maxTokens / 2, then RPCs will not | ||||
| 	// be retried and hedged RPCs will not be sent. | ||||
| 	retryThrottling *retryThrottlingPolicy | ||||
| 	// healthCheckConfig must be set as one of the requirement to enable LB channel | ||||
| 	// health check. | ||||
| 	healthCheckConfig *healthCheckConfig | ||||
| } | ||||
|  | ||||
| // healthCheckConfig defines the go-native version of the LB channel health check config. | ||||
| type healthCheckConfig struct { | ||||
| 	// serviceName is the service name to use in the health-checking request. | ||||
| 	ServiceName string | ||||
| } | ||||
|  | ||||
| // retryPolicy defines the go-native version of the retry policy defined by the | ||||
| @@ -226,6 +235,7 @@ type jsonSC struct { | ||||
| 	LoadBalancingPolicy *string | ||||
| 	MethodConfig        *[]jsonMC | ||||
| 	RetryThrottling     *retryThrottlingPolicy | ||||
| 	HealthCheckConfig   *healthCheckConfig | ||||
| } | ||||
|  | ||||
| func parseServiceConfig(js string) (ServiceConfig, error) { | ||||
| @@ -242,6 +252,7 @@ func parseServiceConfig(js string) (ServiceConfig, error) { | ||||
| 		LB:                rsc.LoadBalancingPolicy, | ||||
| 		Methods:           make(map[string]MethodConfig), | ||||
| 		retryThrottling:   rsc.RetryThrottling, | ||||
| 		healthCheckConfig: rsc.HealthCheckConfig, | ||||
| 	} | ||||
| 	if rsc.MethodConfig == nil { | ||||
| 		return sc, nil | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/google.golang.org/grpc/stats/handlers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/google.golang.org/grpc/stats/handlers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,9 +19,8 @@ | ||||
| package stats | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"net" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| // ConnTagInfo defines the relevant information needed by connection context tagger. | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/google.golang.org/grpc/stats/stats.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/google.golang.org/grpc/stats/stats.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,10 +24,9 @@ | ||||
| package stats // import "google.golang.org/grpc/stats" | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"net" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| // RPCStats contains stats information about RPCs. | ||||
|   | ||||
							
								
								
									
										42
									
								
								vendor/google.golang.org/grpc/status/go16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										42
									
								
								vendor/google.golang.org/grpc/status/go16.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,42 +0,0 @@ | ||||
| // +build go1.6,!go1.7 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 status | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| ) | ||||
|  | ||||
| // FromContextError converts a context error into a Status.  It returns a | ||||
| // Status with codes.OK if err is nil, or a Status with codes.Unknown if err is | ||||
| // non-nil and not a context error. | ||||
| func FromContextError(err error) *Status { | ||||
| 	switch err { | ||||
| 	case nil: | ||||
| 		return New(codes.OK, "") | ||||
| 	case context.DeadlineExceeded: | ||||
| 		return New(codes.DeadlineExceeded, err.Error()) | ||||
| 	case context.Canceled: | ||||
| 		return New(codes.Canceled, err.Error()) | ||||
| 	default: | ||||
| 		return New(codes.Unknown, err.Error()) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										44
									
								
								vendor/google.golang.org/grpc/status/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										44
									
								
								vendor/google.golang.org/grpc/status/go17.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,44 +0,0 @@ | ||||
| // +build go1.7 | ||||
|  | ||||
| /* | ||||
|  * | ||||
|  * Copyright 2018 gRPC authors. | ||||
|  * | ||||
|  * 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 status | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	netctx "golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| ) | ||||
|  | ||||
| // FromContextError converts a context error into a Status.  It returns a | ||||
| // Status with codes.OK if err is nil, or a Status with codes.Unknown if err is | ||||
| // non-nil and not a context error. | ||||
| func FromContextError(err error) *Status { | ||||
| 	switch err { | ||||
| 	case nil: | ||||
| 		return New(codes.OK, "") | ||||
| 	case context.DeadlineExceeded, netctx.DeadlineExceeded: | ||||
| 		return New(codes.DeadlineExceeded, err.Error()) | ||||
| 	case context.Canceled, netctx.Canceled: | ||||
| 		return New(codes.Canceled, err.Error()) | ||||
| 	default: | ||||
| 		return New(codes.Unknown, err.Error()) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										17
									
								
								vendor/google.golang.org/grpc/status/status.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								vendor/google.golang.org/grpc/status/status.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -28,6 +28,7 @@ | ||||
| package status | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| @@ -191,3 +192,19 @@ func Code(err error) codes.Code { | ||||
| 	} | ||||
| 	return codes.Unknown | ||||
| } | ||||
|  | ||||
| // FromContextError converts a context error into a Status.  It returns a | ||||
| // Status with codes.OK if err is nil, or a Status with codes.Unknown if err is | ||||
| // non-nil and not a context error. | ||||
| func FromContextError(err error) *Status { | ||||
| 	switch err { | ||||
| 	case nil: | ||||
| 		return New(codes.OK, "") | ||||
| 	case context.DeadlineExceeded: | ||||
| 		return New(codes.DeadlineExceeded, err.Error()) | ||||
| 	case context.Canceled: | ||||
| 		return New(codes.Canceled, err.Error()) | ||||
| 	default: | ||||
| 		return New(codes.Unknown, err.Error()) | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										500
									
								
								vendor/google.golang.org/grpc/stream.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										500
									
								
								vendor/google.golang.org/grpc/stream.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,6 +19,7 @@ | ||||
| package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"io" | ||||
| 	"math" | ||||
| @@ -26,16 +27,18 @@ import ( | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| 	"golang.org/x/net/trace" | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/connectivity" | ||||
| 	"google.golang.org/grpc/encoding" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| 	"google.golang.org/grpc/internal/binarylog" | ||||
| 	"google.golang.org/grpc/internal/channelz" | ||||
| 	"google.golang.org/grpc/internal/grpcrand" | ||||
| 	"google.golang.org/grpc/internal/transport" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
| 	"google.golang.org/grpc/peer" | ||||
| 	"google.golang.org/grpc/stats" | ||||
| 	"google.golang.org/grpc/status" | ||||
| ) | ||||
| @@ -82,7 +85,8 @@ type ClientStream interface { | ||||
| 	// stream.Recv has returned a non-nil error (including io.EOF). | ||||
| 	Trailer() metadata.MD | ||||
| 	// CloseSend closes the send direction of the stream. It closes the stream | ||||
| 	// when non-nil error is met. | ||||
| 	// when non-nil error is met. It is also not safe to call CloseSend | ||||
| 	// concurrently with SendMsg. | ||||
| 	CloseSend() error | ||||
| 	// Context returns the context for this stream. | ||||
| 	// | ||||
| @@ -105,7 +109,8 @@ type ClientStream interface { | ||||
| 	// | ||||
| 	// It is safe to have a goroutine calling SendMsg and another goroutine | ||||
| 	// calling RecvMsg on the same stream at the same time, but it is not safe | ||||
| 	// to call SendMsg on the same stream in different goroutines. | ||||
| 	// to call SendMsg on the same stream in different goroutines. It is also | ||||
| 	// not safe to call CloseSend concurrently with SendMsg. | ||||
| 	SendMsg(m interface{}) error | ||||
| 	// RecvMsg blocks until it receives a message into m or the stream is | ||||
| 	// done. It returns io.EOF when the stream completes successfully. On | ||||
| @@ -160,6 +165,11 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth | ||||
| 		}() | ||||
| 	} | ||||
| 	c := defaultCallInfo() | ||||
| 	// Provide an opportunity for the first RPC to see the first service config | ||||
| 	// provided by the resolver. | ||||
| 	if err := cc.waitForResolvedAddrs(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	mc := cc.GetMethodConfig(method) | ||||
| 	if mc.WaitForReady != nil { | ||||
| 		c.failFast = !*mc.WaitForReady | ||||
| @@ -262,6 +272,7 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth | ||||
| 	if !cc.dopts.disableRetry { | ||||
| 		cs.retryThrottler = cc.retryThrottler.Load().(*retryThrottler) | ||||
| 	} | ||||
| 	cs.binlog = binarylog.GetMethodLogger(method) | ||||
|  | ||||
| 	cs.callInfo.stream = cs | ||||
| 	// Only this initial attempt has stats/tracing. | ||||
| @@ -277,6 +288,23 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	if cs.binlog != nil { | ||||
| 		md, _ := metadata.FromOutgoingContext(ctx) | ||||
| 		logEntry := &binarylog.ClientHeader{ | ||||
| 			OnClientSide: true, | ||||
| 			Header:       md, | ||||
| 			MethodName:   method, | ||||
| 			Authority:    cs.cc.authority, | ||||
| 		} | ||||
| 		if deadline, ok := ctx.Deadline(); ok { | ||||
| 			logEntry.Timeout = deadline.Sub(time.Now()) | ||||
| 			if logEntry.Timeout < 0 { | ||||
| 				logEntry.Timeout = 0 | ||||
| 			} | ||||
| 		} | ||||
| 		cs.binlog.Log(logEntry) | ||||
| 	} | ||||
|  | ||||
| 	if desc != unaryStreamDesc { | ||||
| 		// Listen on cc and stream contexts to cleanup when the user closes the | ||||
| 		// ClientConn or cancels the stream context.  In all other cases, an error | ||||
| @@ -350,6 +378,15 @@ type clientStream struct { | ||||
|  | ||||
| 	retryThrottler *retryThrottler // The throttler active when the RPC began. | ||||
|  | ||||
| 	binlog *binarylog.MethodLogger // Binary logger, can be nil. | ||||
| 	// serverHeaderBinlogged is a boolean for whether server header has been | ||||
| 	// logged. Server header will be logged when the first time one of those | ||||
| 	// happens: stream.Header(), stream.Recv(). | ||||
| 	// | ||||
| 	// It's only read and used by Recv() and Header(), so it doesn't need to be | ||||
| 	// synchronized. | ||||
| 	serverHeaderBinlogged bool | ||||
|  | ||||
| 	mu                      sync.Mutex | ||||
| 	firstAttempt            bool       // if true, transparent retry is valid | ||||
| 	numRetries              int        // exclusive of transparent retry attempt(s) | ||||
| @@ -561,6 +598,20 @@ func (cs *clientStream) Header() (metadata.MD, error) { | ||||
| 	}, cs.commitAttemptLocked) | ||||
| 	if err != nil { | ||||
| 		cs.finish(err) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if cs.binlog != nil && !cs.serverHeaderBinlogged { | ||||
| 		// Only log if binary log is on and header has not been logged. | ||||
| 		logEntry := &binarylog.ServerHeader{ | ||||
| 			OnClientSide: true, | ||||
| 			Header:       m, | ||||
| 			PeerAddr:     nil, | ||||
| 		} | ||||
| 		if peer, ok := peer.FromContext(cs.Context()); ok { | ||||
| 			logEntry.PeerAddr = peer.Addr | ||||
| 		} | ||||
| 		cs.binlog.Log(logEntry) | ||||
| 		cs.serverHeaderBinlogged = true | ||||
| 	} | ||||
| 	return m, err | ||||
| } | ||||
| @@ -633,6 +684,7 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) { | ||||
| 	if len(payload) > *cs.callInfo.maxSendMessageSize { | ||||
| 		return status.Errorf(codes.ResourceExhausted, "trying to send message larger than max (%d vs. %d)", len(payload), *cs.callInfo.maxSendMessageSize) | ||||
| 	} | ||||
| 	msgBytes := data // Store the pointer before setting to nil. For binary logging. | ||||
| 	op := func(a *csAttempt) error { | ||||
| 		err := a.sendMsg(m, hdr, payload, data) | ||||
| 		// nil out the message and uncomp when replaying; they are only needed for | ||||
| @@ -640,16 +692,53 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) { | ||||
| 		m, data = nil, nil | ||||
| 		return err | ||||
| 	} | ||||
| 	return cs.withRetry(op, func() { cs.bufferForRetryLocked(len(hdr)+len(payload), op) }) | ||||
| 	err = cs.withRetry(op, func() { cs.bufferForRetryLocked(len(hdr)+len(payload), op) }) | ||||
| 	if cs.binlog != nil && err == nil { | ||||
| 		cs.binlog.Log(&binarylog.ClientMessage{ | ||||
| 			OnClientSide: true, | ||||
| 			Message:      msgBytes, | ||||
| 		}) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (cs *clientStream) RecvMsg(m interface{}) error { | ||||
| 	if cs.binlog != nil && !cs.serverHeaderBinlogged { | ||||
| 		// Call Header() to binary log header if it's not already logged. | ||||
| 		cs.Header() | ||||
| 	} | ||||
| 	var recvInfo *payloadInfo | ||||
| 	if cs.binlog != nil { | ||||
| 		recvInfo = &payloadInfo{} | ||||
| 	} | ||||
| 	err := cs.withRetry(func(a *csAttempt) error { | ||||
| 		return a.recvMsg(m) | ||||
| 		return a.recvMsg(m, recvInfo) | ||||
| 	}, cs.commitAttemptLocked) | ||||
| 	if cs.binlog != nil && err == nil { | ||||
| 		cs.binlog.Log(&binarylog.ServerMessage{ | ||||
| 			OnClientSide: true, | ||||
| 			Message:      recvInfo.uncompressedBytes, | ||||
| 		}) | ||||
| 	} | ||||
| 	if err != nil || !cs.desc.ServerStreams { | ||||
| 		// err != nil or non-server-streaming indicates end of stream. | ||||
| 		cs.finish(err) | ||||
|  | ||||
| 		if cs.binlog != nil { | ||||
| 			// finish will not log Trailer. Log Trailer here. | ||||
| 			logEntry := &binarylog.ServerTrailer{ | ||||
| 				OnClientSide: true, | ||||
| 				Trailer:      cs.Trailer(), | ||||
| 				Err:          err, | ||||
| 			} | ||||
| 			if logEntry.Err == io.EOF { | ||||
| 				logEntry.Err = nil | ||||
| 			} | ||||
| 			if peer, ok := peer.FromContext(cs.Context()); ok { | ||||
| 				logEntry.PeerAddr = peer.Addr | ||||
| 			} | ||||
| 			cs.binlog.Log(logEntry) | ||||
| 		} | ||||
| 	} | ||||
| 	return err | ||||
| } | ||||
| @@ -669,6 +758,11 @@ func (cs *clientStream) CloseSend() error { | ||||
| 		return nil | ||||
| 	} | ||||
| 	cs.withRetry(op, func() { cs.bufferForRetryLocked(0, op) }) | ||||
| 	if cs.binlog != nil { | ||||
| 		cs.binlog.Log(&binarylog.ClientHalfClose{ | ||||
| 			OnClientSide: true, | ||||
| 		}) | ||||
| 	} | ||||
| 	// We never returned an error here for reasons. | ||||
| 	return nil | ||||
| } | ||||
| @@ -686,6 +780,16 @@ func (cs *clientStream) finish(err error) { | ||||
| 	cs.finished = true | ||||
| 	cs.commitAttemptLocked() | ||||
| 	cs.mu.Unlock() | ||||
| 	// For binary logging. only log cancel in finish (could be caused by RPC ctx | ||||
| 	// canceled or ClientConn closed). Trailer will be logged in RecvMsg. | ||||
| 	// | ||||
| 	// Only one of cancel or trailer needs to be logged. In the cases where | ||||
| 	// users don't call RecvMsg, users must have already canceled the RPC. | ||||
| 	if cs.binlog != nil && status.Code(err) == codes.Canceled { | ||||
| 		cs.binlog.Log(&binarylog.Cancel{ | ||||
| 			OnClientSide: true, | ||||
| 		}) | ||||
| 	} | ||||
| 	if err == nil { | ||||
| 		cs.retryThrottler.successfulRPC() | ||||
| 	} | ||||
| @@ -735,14 +839,12 @@ func (a *csAttempt) sendMsg(m interface{}, hdr, payld, data []byte) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (a *csAttempt) recvMsg(m interface{}) (err error) { | ||||
| func (a *csAttempt) recvMsg(m interface{}, payInfo *payloadInfo) (err error) { | ||||
| 	cs := a.cs | ||||
| 	var inPayload *stats.InPayload | ||||
| 	if a.statsHandler != nil { | ||||
| 		inPayload = &stats.InPayload{ | ||||
| 			Client: true, | ||||
| 		} | ||||
| 	if a.statsHandler != nil && payInfo == nil { | ||||
| 		payInfo = &payloadInfo{} | ||||
| 	} | ||||
|  | ||||
| 	if !a.decompSet { | ||||
| 		// Block until we receive headers containing received message encoding. | ||||
| 		if ct := a.s.RecvCompress(); ct != "" && ct != encoding.Identity { | ||||
| @@ -759,7 +861,7 @@ func (a *csAttempt) recvMsg(m interface{}) (err error) { | ||||
| 		// Only initialize this state once per stream. | ||||
| 		a.decompSet = true | ||||
| 	} | ||||
| 	err = recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, inPayload, a.decomp) | ||||
| 	err = recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, payInfo, a.decomp) | ||||
| 	if err != nil { | ||||
| 		if err == io.EOF { | ||||
| 			if statusErr := a.s.Status().Err(); statusErr != nil { | ||||
| @@ -776,8 +878,15 @@ func (a *csAttempt) recvMsg(m interface{}) (err error) { | ||||
| 		} | ||||
| 		a.mu.Unlock() | ||||
| 	} | ||||
| 	if inPayload != nil { | ||||
| 		a.statsHandler.HandleRPC(cs.ctx, inPayload) | ||||
| 	if a.statsHandler != nil { | ||||
| 		a.statsHandler.HandleRPC(cs.ctx, &stats.InPayload{ | ||||
| 			Client:   true, | ||||
| 			RecvTime: time.Now(), | ||||
| 			Payload:  m, | ||||
| 			// TODO truncate large payload. | ||||
| 			Data:   payInfo.uncompressedBytes, | ||||
| 			Length: len(payInfo.uncompressedBytes), | ||||
| 		}) | ||||
| 	} | ||||
| 	if channelz.IsOn() { | ||||
| 		a.t.IncrMsgRecv() | ||||
| @@ -786,7 +895,6 @@ func (a *csAttempt) recvMsg(m interface{}) (err error) { | ||||
| 		// Subsequent messages should be received by subsequent RecvMsg calls. | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	// Special handling for non-server-stream rpcs. | ||||
| 	// This recv expects EOF or errors, so we don't collect inPayload. | ||||
| 	err = recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, nil, a.decomp) | ||||
| @@ -850,6 +958,299 @@ func (a *csAttempt) finish(err error) { | ||||
| 	a.mu.Unlock() | ||||
| } | ||||
|  | ||||
| func (ac *addrConn) newClientStream(ctx context.Context, desc *StreamDesc, method string, t transport.ClientTransport, opts ...CallOption) (_ ClientStream, err error) { | ||||
| 	ac.mu.Lock() | ||||
| 	if ac.transport != t { | ||||
| 		ac.mu.Unlock() | ||||
| 		return nil, status.Error(codes.Canceled, "the provided transport is no longer valid to use") | ||||
| 	} | ||||
| 	// transition to CONNECTING state when an attempt starts | ||||
| 	if ac.state != connectivity.Connecting { | ||||
| 		ac.updateConnectivityState(connectivity.Connecting) | ||||
| 		ac.cc.handleSubConnStateChange(ac.acbw, ac.state) | ||||
| 	} | ||||
| 	ac.mu.Unlock() | ||||
|  | ||||
| 	if t == nil { | ||||
| 		// TODO: return RPC error here? | ||||
| 		return nil, errors.New("transport provided is nil") | ||||
| 	} | ||||
| 	// defaultCallInfo contains unnecessary info(i.e. failfast, maxRetryRPCBufferSize), so we just initialize an empty struct. | ||||
| 	c := &callInfo{} | ||||
|  | ||||
| 	for _, o := range opts { | ||||
| 		if err := o.before(c); err != nil { | ||||
| 			return nil, toRPCErr(err) | ||||
| 		} | ||||
| 	} | ||||
| 	c.maxReceiveMessageSize = getMaxSize(nil, c.maxReceiveMessageSize, defaultClientMaxReceiveMessageSize) | ||||
| 	c.maxSendMessageSize = getMaxSize(nil, c.maxSendMessageSize, defaultServerMaxSendMessageSize) | ||||
|  | ||||
| 	// Possible context leak: | ||||
| 	// The cancel function for the child context we create will only be called | ||||
| 	// when RecvMsg returns a non-nil error, if the ClientConn is closed, or if | ||||
| 	// an error is generated by SendMsg. | ||||
| 	// https://github.com/grpc/grpc-go/issues/1818. | ||||
| 	ctx, cancel := context.WithCancel(ctx) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			cancel() | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	if err := setCallInfoCodec(c); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	callHdr := &transport.CallHdr{ | ||||
| 		Host:           ac.cc.authority, | ||||
| 		Method:         method, | ||||
| 		ContentSubtype: c.contentSubtype, | ||||
| 	} | ||||
|  | ||||
| 	// Set our outgoing compression according to the UseCompressor CallOption, if | ||||
| 	// set.  In that case, also find the compressor from the encoding package. | ||||
| 	// Otherwise, use the compressor configured by the WithCompressor DialOption, | ||||
| 	// if set. | ||||
| 	var cp Compressor | ||||
| 	var comp encoding.Compressor | ||||
| 	if ct := c.compressorType; ct != "" { | ||||
| 		callHdr.SendCompress = ct | ||||
| 		if ct != encoding.Identity { | ||||
| 			comp = encoding.GetCompressor(ct) | ||||
| 			if comp == nil { | ||||
| 				return nil, status.Errorf(codes.Internal, "grpc: Compressor is not installed for requested grpc-encoding %q", ct) | ||||
| 			} | ||||
| 		} | ||||
| 	} else if ac.cc.dopts.cp != nil { | ||||
| 		callHdr.SendCompress = ac.cc.dopts.cp.Type() | ||||
| 		cp = ac.cc.dopts.cp | ||||
| 	} | ||||
| 	if c.creds != nil { | ||||
| 		callHdr.Creds = c.creds | ||||
| 	} | ||||
|  | ||||
| 	as := &addrConnStream{ | ||||
| 		callHdr:  callHdr, | ||||
| 		ac:       ac, | ||||
| 		ctx:      ctx, | ||||
| 		cancel:   cancel, | ||||
| 		opts:     opts, | ||||
| 		callInfo: c, | ||||
| 		desc:     desc, | ||||
| 		codec:    c.codec, | ||||
| 		cp:       cp, | ||||
| 		comp:     comp, | ||||
| 		t:        t, | ||||
| 	} | ||||
|  | ||||
| 	as.callInfo.stream = as | ||||
| 	s, err := as.t.NewStream(as.ctx, as.callHdr) | ||||
| 	if err != nil { | ||||
| 		err = toRPCErr(err) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	as.s = s | ||||
| 	as.p = &parser{r: s} | ||||
| 	ac.incrCallsStarted() | ||||
| 	if desc != unaryStreamDesc { | ||||
| 		// Listen on cc and stream contexts to cleanup when the user closes the | ||||
| 		// ClientConn or cancels the stream context.  In all other cases, an error | ||||
| 		// should already be injected into the recv buffer by the transport, which | ||||
| 		// the client will eventually receive, and then we will cancel the stream's | ||||
| 		// context in clientStream.finish. | ||||
| 		go func() { | ||||
| 			select { | ||||
| 			case <-ac.ctx.Done(): | ||||
| 				as.finish(status.Error(codes.Canceled, "grpc: the SubConn is closing")) | ||||
| 			case <-ctx.Done(): | ||||
| 				as.finish(toRPCErr(ctx.Err())) | ||||
| 			} | ||||
| 		}() | ||||
| 	} | ||||
| 	return as, nil | ||||
| } | ||||
|  | ||||
| type addrConnStream struct { | ||||
| 	s         *transport.Stream | ||||
| 	ac        *addrConn | ||||
| 	callHdr   *transport.CallHdr | ||||
| 	cancel    context.CancelFunc | ||||
| 	opts      []CallOption | ||||
| 	callInfo  *callInfo | ||||
| 	t         transport.ClientTransport | ||||
| 	ctx       context.Context | ||||
| 	sentLast  bool | ||||
| 	desc      *StreamDesc | ||||
| 	codec     baseCodec | ||||
| 	cp        Compressor | ||||
| 	comp      encoding.Compressor | ||||
| 	decompSet bool | ||||
| 	dc        Decompressor | ||||
| 	decomp    encoding.Compressor | ||||
| 	p         *parser | ||||
| 	done      func(balancer.DoneInfo) | ||||
| 	mu        sync.Mutex | ||||
| 	finished  bool | ||||
| } | ||||
|  | ||||
| func (as *addrConnStream) Header() (metadata.MD, error) { | ||||
| 	m, err := as.s.Header() | ||||
| 	if err != nil { | ||||
| 		as.finish(toRPCErr(err)) | ||||
| 	} | ||||
| 	return m, err | ||||
| } | ||||
|  | ||||
| func (as *addrConnStream) Trailer() metadata.MD { | ||||
| 	return as.s.Trailer() | ||||
| } | ||||
|  | ||||
| func (as *addrConnStream) CloseSend() error { | ||||
| 	if as.sentLast { | ||||
| 		// TODO: return an error and finish the stream instead, due to API misuse? | ||||
| 		return nil | ||||
| 	} | ||||
| 	as.sentLast = true | ||||
|  | ||||
| 	as.t.Write(as.s, nil, nil, &transport.Options{Last: true}) | ||||
| 	// Always return nil; io.EOF is the only error that might make sense | ||||
| 	// instead, but there is no need to signal the client to call RecvMsg | ||||
| 	// as the only use left for the stream after CloseSend is to call | ||||
| 	// RecvMsg.  This also matches historical behavior. | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (as *addrConnStream) Context() context.Context { | ||||
| 	return as.s.Context() | ||||
| } | ||||
|  | ||||
| func (as *addrConnStream) SendMsg(m interface{}) (err error) { | ||||
| 	defer func() { | ||||
| 		if err != nil && err != io.EOF { | ||||
| 			// Call finish on the client stream for errors generated by this SendMsg | ||||
| 			// call, as these indicate problems created by this client.  (Transport | ||||
| 			// errors are converted to an io.EOF error in csAttempt.sendMsg; the real | ||||
| 			// error will be returned from RecvMsg eventually in that case, or be | ||||
| 			// retried.) | ||||
| 			as.finish(err) | ||||
| 		} | ||||
| 	}() | ||||
| 	if as.sentLast { | ||||
| 		return status.Errorf(codes.Internal, "SendMsg called after CloseSend") | ||||
| 	} | ||||
| 	if !as.desc.ClientStreams { | ||||
| 		as.sentLast = true | ||||
| 	} | ||||
| 	data, err := encode(as.codec, m) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	compData, err := compress(data, as.cp, as.comp) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	hdr, payld := msgHeader(data, compData) | ||||
| 	// TODO(dfawley): should we be checking len(data) instead? | ||||
| 	if len(payld) > *as.callInfo.maxSendMessageSize { | ||||
| 		return status.Errorf(codes.ResourceExhausted, "trying to send message larger than max (%d vs. %d)", len(payld), *as.callInfo.maxSendMessageSize) | ||||
| 	} | ||||
|  | ||||
| 	if err := as.t.Write(as.s, hdr, payld, &transport.Options{Last: !as.desc.ClientStreams}); err != nil { | ||||
| 		if !as.desc.ClientStreams { | ||||
| 			// For non-client-streaming RPCs, we return nil instead of EOF on error | ||||
| 			// because the generated code requires it.  finish is not called; RecvMsg() | ||||
| 			// will call it with the stream's status independently. | ||||
| 			return nil | ||||
| 		} | ||||
| 		return io.EOF | ||||
| 	} | ||||
|  | ||||
| 	if channelz.IsOn() { | ||||
| 		as.t.IncrMsgSent() | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (as *addrConnStream) RecvMsg(m interface{}) (err error) { | ||||
| 	defer func() { | ||||
| 		if err != nil || !as.desc.ServerStreams { | ||||
| 			// err != nil or non-server-streaming indicates end of stream. | ||||
| 			as.finish(err) | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	if !as.decompSet { | ||||
| 		// Block until we receive headers containing received message encoding. | ||||
| 		if ct := as.s.RecvCompress(); ct != "" && ct != encoding.Identity { | ||||
| 			if as.dc == nil || as.dc.Type() != ct { | ||||
| 				// No configured decompressor, or it does not match the incoming | ||||
| 				// message encoding; attempt to find a registered compressor that does. | ||||
| 				as.dc = nil | ||||
| 				as.decomp = encoding.GetCompressor(ct) | ||||
| 			} | ||||
| 		} else { | ||||
| 			// No compression is used; disable our decompressor. | ||||
| 			as.dc = nil | ||||
| 		} | ||||
| 		// Only initialize this state once per stream. | ||||
| 		as.decompSet = true | ||||
| 	} | ||||
| 	err = recv(as.p, as.codec, as.s, as.dc, m, *as.callInfo.maxReceiveMessageSize, nil, as.decomp) | ||||
| 	if err != nil { | ||||
| 		if err == io.EOF { | ||||
| 			if statusErr := as.s.Status().Err(); statusErr != nil { | ||||
| 				return statusErr | ||||
| 			} | ||||
| 			return io.EOF // indicates successful end of stream. | ||||
| 		} | ||||
| 		return toRPCErr(err) | ||||
| 	} | ||||
|  | ||||
| 	if channelz.IsOn() { | ||||
| 		as.t.IncrMsgRecv() | ||||
| 	} | ||||
| 	if as.desc.ServerStreams { | ||||
| 		// Subsequent messages should be received by subsequent RecvMsg calls. | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	// Special handling for non-server-stream rpcs. | ||||
| 	// This recv expects EOF or errors, so we don't collect inPayload. | ||||
| 	err = recv(as.p, as.codec, as.s, as.dc, m, *as.callInfo.maxReceiveMessageSize, nil, as.decomp) | ||||
| 	if err == nil { | ||||
| 		return toRPCErr(errors.New("grpc: client streaming protocol violation: get <nil>, want <EOF>")) | ||||
| 	} | ||||
| 	if err == io.EOF { | ||||
| 		return as.s.Status().Err() // non-server streaming Recv returns nil on success | ||||
| 	} | ||||
| 	return toRPCErr(err) | ||||
| } | ||||
|  | ||||
| func (as *addrConnStream) finish(err error) { | ||||
| 	as.mu.Lock() | ||||
| 	if as.finished { | ||||
| 		as.mu.Unlock() | ||||
| 		return | ||||
| 	} | ||||
| 	as.finished = true | ||||
| 	if err == io.EOF { | ||||
| 		// Ending a stream with EOF indicates a success. | ||||
| 		err = nil | ||||
| 	} | ||||
| 	if as.s != nil { | ||||
| 		as.t.CloseStream(as.s, err) | ||||
| 	} | ||||
|  | ||||
| 	if err != nil { | ||||
| 		as.ac.incrCallsFailed() | ||||
| 	} else { | ||||
| 		as.ac.incrCallsSucceeded() | ||||
| 	} | ||||
| 	as.cancel() | ||||
| 	as.mu.Unlock() | ||||
| } | ||||
|  | ||||
| // ServerStream defines the server-side behavior of a streaming RPC. | ||||
| // | ||||
| // All errors returned from ServerStream methods are compatible with the | ||||
| @@ -916,6 +1317,15 @@ type serverStream struct { | ||||
|  | ||||
| 	statsHandler stats.Handler | ||||
|  | ||||
| 	binlog *binarylog.MethodLogger | ||||
| 	// serverHeaderBinlogged indicates whether server header has been logged. It | ||||
| 	// will happen when one of the following two happens: stream.SendHeader(), | ||||
| 	// stream.Send(). | ||||
| 	// | ||||
| 	// It's only checked in send and sendHeader, doesn't need to be | ||||
| 	// synchronized. | ||||
| 	serverHeaderBinlogged bool | ||||
|  | ||||
| 	mu sync.Mutex // protects trInfo.tr after the service handler runs. | ||||
| } | ||||
|  | ||||
| @@ -931,7 +1341,15 @@ func (ss *serverStream) SetHeader(md metadata.MD) error { | ||||
| } | ||||
|  | ||||
| func (ss *serverStream) SendHeader(md metadata.MD) error { | ||||
| 	return ss.t.WriteHeader(ss.s, md) | ||||
| 	err := ss.t.WriteHeader(ss.s, md) | ||||
| 	if ss.binlog != nil && !ss.serverHeaderBinlogged { | ||||
| 		h, _ := ss.s.Header() | ||||
| 		ss.binlog.Log(&binarylog.ServerHeader{ | ||||
| 			Header: h, | ||||
| 		}) | ||||
| 		ss.serverHeaderBinlogged = true | ||||
| 	} | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func (ss *serverStream) SetTrailer(md metadata.MD) { | ||||
| @@ -958,6 +1376,12 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) { | ||||
| 		if err != nil && err != io.EOF { | ||||
| 			st, _ := status.FromError(toRPCErr(err)) | ||||
| 			ss.t.WriteStatus(ss.s, st) | ||||
| 			// Non-user specified status was sent out. This should be an error | ||||
| 			// case (as a server side Cancel maybe). | ||||
| 			// | ||||
| 			// This is not handled specifically now. User will return a final | ||||
| 			// status from the service handler, we will log that error instead. | ||||
| 			// This behavior is similar to an interceptor. | ||||
| 		} | ||||
| 		if channelz.IsOn() && err == nil { | ||||
| 			ss.t.IncrMsgSent() | ||||
| @@ -979,6 +1403,18 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) { | ||||
| 	if err := ss.t.Write(ss.s, hdr, payload, &transport.Options{Last: false}); err != nil { | ||||
| 		return toRPCErr(err) | ||||
| 	} | ||||
| 	if ss.binlog != nil { | ||||
| 		if !ss.serverHeaderBinlogged { | ||||
| 			h, _ := ss.s.Header() | ||||
| 			ss.binlog.Log(&binarylog.ServerHeader{ | ||||
| 				Header: h, | ||||
| 			}) | ||||
| 			ss.serverHeaderBinlogged = true | ||||
| 		} | ||||
| 		ss.binlog.Log(&binarylog.ServerMessage{ | ||||
| 			Message: data, | ||||
| 		}) | ||||
| 	} | ||||
| 	if ss.statsHandler != nil { | ||||
| 		ss.statsHandler.HandleRPC(ss.s.Context(), outPayload(false, m, data, payload, time.Now())) | ||||
| 	} | ||||
| @@ -1002,17 +1438,26 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) { | ||||
| 		if err != nil && err != io.EOF { | ||||
| 			st, _ := status.FromError(toRPCErr(err)) | ||||
| 			ss.t.WriteStatus(ss.s, st) | ||||
| 			// Non-user specified status was sent out. This should be an error | ||||
| 			// case (as a server side Cancel maybe). | ||||
| 			// | ||||
| 			// This is not handled specifically now. User will return a final | ||||
| 			// status from the service handler, we will log that error instead. | ||||
| 			// This behavior is similar to an interceptor. | ||||
| 		} | ||||
| 		if channelz.IsOn() && err == nil { | ||||
| 			ss.t.IncrMsgRecv() | ||||
| 		} | ||||
| 	}() | ||||
| 	var inPayload *stats.InPayload | ||||
| 	if ss.statsHandler != nil { | ||||
| 		inPayload = &stats.InPayload{} | ||||
| 	var payInfo *payloadInfo | ||||
| 	if ss.statsHandler != nil || ss.binlog != nil { | ||||
| 		payInfo = &payloadInfo{} | ||||
| 	} | ||||
| 	if err := recv(ss.p, ss.codec, ss.s, ss.dc, m, ss.maxReceiveMessageSize, inPayload, ss.decomp); err != nil { | ||||
| 	if err := recv(ss.p, ss.codec, ss.s, ss.dc, m, ss.maxReceiveMessageSize, payInfo, ss.decomp); err != nil { | ||||
| 		if err == io.EOF { | ||||
| 			if ss.binlog != nil { | ||||
| 				ss.binlog.Log(&binarylog.ClientHalfClose{}) | ||||
| 			} | ||||
| 			return err | ||||
| 		} | ||||
| 		if err == io.ErrUnexpectedEOF { | ||||
| @@ -1020,8 +1465,19 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) { | ||||
| 		} | ||||
| 		return toRPCErr(err) | ||||
| 	} | ||||
| 	if inPayload != nil { | ||||
| 		ss.statsHandler.HandleRPC(ss.s.Context(), inPayload) | ||||
| 	if ss.statsHandler != nil { | ||||
| 		ss.statsHandler.HandleRPC(ss.s.Context(), &stats.InPayload{ | ||||
| 			RecvTime: time.Now(), | ||||
| 			Payload:  m, | ||||
| 			// TODO truncate large payload. | ||||
| 			Data:   payInfo.uncompressedBytes, | ||||
| 			Length: len(payInfo.uncompressedBytes), | ||||
| 		}) | ||||
| 	} | ||||
| 	if ss.binlog != nil { | ||||
| 		ss.binlog.Log(&binarylog.ClientMessage{ | ||||
| 			Message: payInfo.uncompressedBytes, | ||||
| 		}) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/tap/tap.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/tap/tap.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,7 +21,7 @@ | ||||
| package tap | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/net/context" | ||||
| 	"context" | ||||
| ) | ||||
|  | ||||
| // Info defines the relevant information needed by the handles. | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/grpc/version.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/grpc/version.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,4 +19,4 @@ | ||||
| package grpc | ||||
|  | ||||
| // Version is the current grpc version. | ||||
| const Version = "1.16.0" | ||||
| const Version = "1.17.0" | ||||
|   | ||||
							
								
								
									
										63
									
								
								vendor/google.golang.org/grpc/vet.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										63
									
								
								vendor/google.golang.org/grpc/vet.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,13 +29,17 @@ cleanup() { | ||||
| } | ||||
| trap cleanup EXIT | ||||
|  | ||||
| fail_on_output() { | ||||
|   tee /dev/stderr | (! read) | ||||
| } | ||||
|  | ||||
| PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}" | ||||
|  | ||||
| if [[ "$1" = "-install" ]]; then | ||||
|   # Check for module support | ||||
|   if go help mod >& /dev/null; then | ||||
|     go install \ | ||||
|       github.com/golang/lint/golint \ | ||||
|       golang.org/x/lint/golint \ | ||||
|       golang.org/x/tools/cmd/goimports \ | ||||
|       honnef.co/go/tools/cmd/staticcheck \ | ||||
|       github.com/client9/misspell/cmd/misspell \ | ||||
| @@ -45,7 +49,7 @@ if [[ "$1" = "-install" ]]; then | ||||
|     # Note: this gets the latest version of all tools (vs. the pinned versions | ||||
|     # with Go modules). | ||||
|     go get -u \ | ||||
|       github.com/golang/lint/golint \ | ||||
|       golang.org/x/lint/golint \ | ||||
|       golang.org/x/tools/cmd/goimports \ | ||||
|       honnef.co/go/tools/cmd/staticcheck \ | ||||
|       github.com/client9/misspell/cmd/misspell \ | ||||
| @@ -69,40 +73,41 @@ elif [[ "$#" -ne 0 ]]; then | ||||
|   die "Unknown argument(s): $*" | ||||
| fi | ||||
|  | ||||
| git ls-files "*.go" | xargs grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" 2>&1 | tee /dev/stderr | (! read) | ||||
| git ls-files "*.go" | xargs grep -l '"math/rand"' 2>&1 | (! grep -v '^examples\|^stress\|grpcrand') | tee /dev/stderr | (! read) | ||||
| git ls-files | xargs dirname | sort | uniq | xargs go run test/go_vet/vet.go | tee /dev/stderr | (! read) | ||||
| gofmt -s -d -l . 2>&1 | tee /dev/stderr | (! read) | ||||
| goimports -l . 2>&1 | tee /dev/stderr | (! read) | ||||
| golint ./... 2>&1 | (grep -vE "(_mock|\.pb)\.go:" || true) | tee /dev/stderr | (! read) | ||||
| # - Ensure all source files contain a copyright message. | ||||
| git ls-files "*.go" | xargs grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" 2>&1 | fail_on_output | ||||
|  | ||||
| # Rewrite golang.org/x/net/context -> context imports (see grpc/grpc-go#1484). | ||||
| # TODO: Remove this mangling once "context" is imported directly (grpc/grpc-go#711). | ||||
| git ls-files "*.go" | xargs sed -i 's:"golang.org/x/net/context":"context":' | ||||
| set +o pipefail # vet exits with non-zero error if issues are found | ||||
| # - Do not import math/rand for real library code.  Use internal/grpcrand for | ||||
| #   thread safety. | ||||
| git ls-files "*.go" | xargs grep -l '"math/rand"' 2>&1 | (! grep -v '^examples\|^stress\|grpcrand') | ||||
|  | ||||
| # TODO(deklerk) remove when we drop Go 1.6 support | ||||
| go tool vet -all . 2>&1 | \ | ||||
|     grep -vE 'clientconn.go:.*cancel (function|var)' | \ | ||||
|     grep -vE '.*transport_test.go:.*cancel' | \ | ||||
|     tee /dev/stderr | \ | ||||
|     (! read) | ||||
| # - Ensure all ptypes proto packages are renamed when importing. | ||||
| git ls-files "*.go" | (! xargs grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/") | ||||
|  | ||||
| set -o pipefail | ||||
| git reset --hard HEAD | ||||
| # - Check imports that are illegal in appengine (until Go 1.11). | ||||
| # TODO: Remove when we drop Go 1.10 support | ||||
| go list -f {{.Dir}} ./... | xargs go run test/go_vet/vet.go | ||||
|  | ||||
| # - gofmt, goimports, golint (with exceptions for generated code), go vet. | ||||
| gofmt -s -d -l . 2>&1 | fail_on_output | ||||
| goimports -l . 2>&1 | fail_on_output | ||||
| golint ./... 2>&1 | (! grep -vE "(_mock|\.pb)\.go:") | ||||
| go tool vet -all . | ||||
|  | ||||
| # - Check that generated proto files are up to date. | ||||
| if [[ -z "${VET_SKIP_PROTO}" ]]; then | ||||
|   PATH="/home/travis/bin:${PATH}" make proto && \ | ||||
|     git status --porcelain 2>&1 | (! read) || \ | ||||
|     git status --porcelain 2>&1 | fail_on_output || \ | ||||
|     (git status; git --no-pager diff; exit 1) | ||||
| fi | ||||
|  | ||||
| # - Check that our module is tidy. | ||||
| if go help mod >& /dev/null; then | ||||
|   go mod tidy && \ | ||||
|     git status --porcelain 2>&1 | (! read) || \ | ||||
|     git status --porcelain 2>&1 | fail_on_output || \ | ||||
|     (git status; git --no-pager diff; exit 1) | ||||
| fi | ||||
|  | ||||
| # - Collection of static analysis checks | ||||
| ### HACK HACK HACK: Remove once staticcheck works with modules. | ||||
| # Make a symlink in ${GOPATH}/src to its ${GOPATH}/pkg/mod equivalent for every package we use. | ||||
| for x in $(find "${GOPATH}/pkg/mod" -name '*@*' | grep -v \/mod\/cache\/); do | ||||
| @@ -116,14 +121,16 @@ done | ||||
|  | ||||
| # TODO(menghanl): fix errors in transport_test. | ||||
| staticcheck -ignore ' | ||||
| internal/transport/transport_test.go:SA2002 | ||||
| benchmark/benchmain/main.go:SA1019 | ||||
| stats/stats_test.go:SA1019 | ||||
| test/end2end_test.go:SA1019 | ||||
| balancer_test.go:SA1019 | ||||
| balancer.go:SA1019 | ||||
| balancer_test.go:SA1019 | ||||
| clientconn_test.go:SA1019 | ||||
| internal/transport/handler_server_test.go:SA1019 | ||||
| balancer/roundrobin/roundrobin_test.go:SA1019 | ||||
| benchmark/benchmain/main.go:SA1019 | ||||
| internal/transport/handler_server.go:SA1019 | ||||
| internal/transport/handler_server_test.go:SA1019 | ||||
| internal/transport/transport_test.go:SA2002 | ||||
| stats/stats_test.go:SA1019 | ||||
| test/channelz_test.go:SA1019 | ||||
| test/end2end_test.go:SA1019 | ||||
| ' ./... | ||||
| misspell -error . | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							| @@ -221,7 +221,7 @@ google.golang.org/api/support/bundler | ||||
| google.golang.org/appengine/cloudsql | ||||
| # google.golang.org/genproto v0.0.0-20181016170114-94acd270e44e | ||||
| google.golang.org/genproto/googleapis/rpc/status | ||||
| # google.golang.org/grpc v1.16.0 | ||||
| # google.golang.org/grpc v1.17.0 | ||||
| google.golang.org/grpc | ||||
| google.golang.org/grpc/codes | ||||
| google.golang.org/grpc/credentials | ||||
| @@ -236,9 +236,11 @@ google.golang.org/grpc/encoding/proto | ||||
| google.golang.org/grpc/grpclog | ||||
| google.golang.org/grpc/internal | ||||
| google.golang.org/grpc/internal/backoff | ||||
| google.golang.org/grpc/internal/binarylog | ||||
| google.golang.org/grpc/internal/channelz | ||||
| google.golang.org/grpc/internal/envconfig | ||||
| google.golang.org/grpc/internal/grpcrand | ||||
| google.golang.org/grpc/internal/grpcsync | ||||
| google.golang.org/grpc/internal/transport | ||||
| google.golang.org/grpc/keepalive | ||||
| google.golang.org/grpc/naming | ||||
| @@ -247,7 +249,10 @@ google.golang.org/grpc/resolver/dns | ||||
| google.golang.org/grpc/resolver/passthrough | ||||
| google.golang.org/grpc/stats | ||||
| google.golang.org/grpc/tap | ||||
| google.golang.org/grpc/credentials/internal | ||||
| google.golang.org/grpc/balancer/base | ||||
| google.golang.org/grpc/binarylog/grpc_binarylog_v1 | ||||
| google.golang.org/grpc/internal/syscall | ||||
| # gopkg.in/go-playground/validator.v8 v8.18.2 | ||||
| gopkg.in/go-playground/validator.v8 | ||||
| # gopkg.in/yaml.v2 v2.2.1 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tolga Ceylan
					Tolga Ceylan