mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
rebase: bump google.golang.org/grpc from 1.41.0 to 1.42.0
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.41.0 to 1.42.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.41.0...v1.42.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
fac3ef01c6
commit
335c945d97
2
go.mod
2
go.mod
@ -24,7 +24,7 @@ require (
|
|||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
|
||||||
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2
|
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2
|
||||||
google.golang.org/grpc v1.41.0
|
google.golang.org/grpc v1.42.0
|
||||||
k8s.io/api v0.22.2
|
k8s.io/api v0.22.2
|
||||||
k8s.io/apimachinery v0.22.2
|
k8s.io/apimachinery v0.22.2
|
||||||
k8s.io/client-go v12.0.0+incompatible
|
k8s.io/client-go v12.0.0+incompatible
|
||||||
|
6
go.sum
6
go.sum
@ -183,7 +183,10 @@ github.com/cloudfoundry/gofileutils v0.0.0-20170111115228-4d0c80011a0f/go.mod h1
|
|||||||
github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313/go.mod h1:P1wt9Z3DP8O6W3rvwCt0REIlshg1InHImaLW0t3ObY0=
|
github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313/go.mod h1:P1wt9Z3DP8O6W3rvwCt0REIlshg1InHImaLW0t3ObY0=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||||
github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk=
|
github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk=
|
||||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||||
@ -1504,8 +1507,9 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG
|
|||||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||||
google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||||
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||||
google.golang.org/grpc v1.41.0 h1:f+PlOh7QV4iIJkPrx5NQ7qaNGFQ3OTse67yaDHfju4E=
|
|
||||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||||
|
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
|
||||||
|
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
78
vendor/google.golang.org/grpc/attributes/attributes.go
generated
vendored
78
vendor/google.golang.org/grpc/attributes/attributes.go
generated
vendored
@ -25,55 +25,75 @@
|
|||||||
// later release.
|
// later release.
|
||||||
package attributes
|
package attributes
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Attributes is an immutable struct for storing and retrieving generic
|
// Attributes is an immutable struct for storing and retrieving generic
|
||||||
// key/value pairs. Keys must be hashable, and users should define their own
|
// key/value pairs. Keys must be hashable, and users should define their own
|
||||||
// types for keys.
|
// types for keys. Values should not be modified after they are added to an
|
||||||
|
// Attributes or if they were received from one. If values implement 'Equal(o
|
||||||
|
// interface{}) bool', it will be called by (*Attributes).Equal to determine
|
||||||
|
// whether two values with the same key should be considered equal.
|
||||||
type Attributes struct {
|
type Attributes struct {
|
||||||
m map[interface{}]interface{}
|
m map[interface{}]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new Attributes containing all key/value pairs in kvs. If the
|
// New returns a new Attributes containing the key/value pair.
|
||||||
// same key appears multiple times, the last value overwrites all previous
|
func New(key, value interface{}) *Attributes {
|
||||||
// values for that key. Panics if len(kvs) is not even.
|
return &Attributes{m: map[interface{}]interface{}{key: value}}
|
||||||
func New(kvs ...interface{}) *Attributes {
|
|
||||||
if len(kvs)%2 != 0 {
|
|
||||||
panic(fmt.Sprintf("attributes.New called with unexpected input: len(kvs) = %v", len(kvs)))
|
|
||||||
}
|
|
||||||
a := &Attributes{m: make(map[interface{}]interface{}, len(kvs)/2)}
|
|
||||||
for i := 0; i < len(kvs)/2; i++ {
|
|
||||||
a.m[kvs[i*2]] = kvs[i*2+1]
|
|
||||||
}
|
|
||||||
return a
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithValues returns a new Attributes containing all key/value pairs in a and
|
// WithValue returns a new Attributes containing the previous keys and values
|
||||||
// kvs. Panics if len(kvs) is not even. If the same key appears multiple
|
// and the new key/value pair. If the same key appears multiple times, the
|
||||||
// times, the last value overwrites all previous values for that key. To
|
// last value overwrites all previous values for that key. To remove an
|
||||||
// remove an existing key, use a nil value.
|
// existing key, use a nil value. value should not be modified later.
|
||||||
func (a *Attributes) WithValues(kvs ...interface{}) *Attributes {
|
func (a *Attributes) WithValue(key, value interface{}) *Attributes {
|
||||||
if a == nil {
|
if a == nil {
|
||||||
return New(kvs...)
|
return New(key, value)
|
||||||
}
|
}
|
||||||
if len(kvs)%2 != 0 {
|
n := &Attributes{m: make(map[interface{}]interface{}, len(a.m)+1)}
|
||||||
panic(fmt.Sprintf("attributes.New called with unexpected input: len(kvs) = %v", len(kvs)))
|
|
||||||
}
|
|
||||||
n := &Attributes{m: make(map[interface{}]interface{}, len(a.m)+len(kvs)/2)}
|
|
||||||
for k, v := range a.m {
|
for k, v := range a.m {
|
||||||
n.m[k] = v
|
n.m[k] = v
|
||||||
}
|
}
|
||||||
for i := 0; i < len(kvs)/2; i++ {
|
n.m[key] = value
|
||||||
n.m[kvs[i*2]] = kvs[i*2+1]
|
|
||||||
}
|
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value returns the value associated with these attributes for key, or nil if
|
// Value returns the value associated with these attributes for key, or nil if
|
||||||
// no value is associated with key.
|
// no value is associated with key. The returned value should not be modified.
|
||||||
func (a *Attributes) Value(key interface{}) interface{} {
|
func (a *Attributes) Value(key interface{}) interface{} {
|
||||||
if a == nil {
|
if a == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return a.m[key]
|
return a.m[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Equal returns whether a and o are equivalent. If 'Equal(o interface{})
|
||||||
|
// bool' is implemented for a value in the attributes, it is called to
|
||||||
|
// determine if the value matches the one stored in the other attributes. If
|
||||||
|
// Equal is not implemented, standard equality is used to determine if the two
|
||||||
|
// values are equal.
|
||||||
|
func (a *Attributes) Equal(o *Attributes) bool {
|
||||||
|
if a == nil && o == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if a == nil || o == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(a.m) != len(o.m) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for k, v := range a.m {
|
||||||
|
ov, ok := o.m[k]
|
||||||
|
if !ok {
|
||||||
|
// o missing element of a
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if eq, ok := v.(interface{ Equal(o interface{}) bool }); ok {
|
||||||
|
if !eq.Equal(ov) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} else if v != ov {
|
||||||
|
// Fallback to a standard equality check if Value is unimplemented.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
65
vendor/google.golang.org/grpc/balancer/base/balancer.go
generated
vendored
65
vendor/google.golang.org/grpc/balancer/base/balancer.go
generated
vendored
@ -22,7 +22,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"google.golang.org/grpc/attributes"
|
|
||||||
"google.golang.org/grpc/balancer"
|
"google.golang.org/grpc/balancer"
|
||||||
"google.golang.org/grpc/connectivity"
|
"google.golang.org/grpc/connectivity"
|
||||||
"google.golang.org/grpc/grpclog"
|
"google.golang.org/grpc/grpclog"
|
||||||
@ -42,7 +41,7 @@ func (bb *baseBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions)
|
|||||||
cc: cc,
|
cc: cc,
|
||||||
pickerBuilder: bb.pickerBuilder,
|
pickerBuilder: bb.pickerBuilder,
|
||||||
|
|
||||||
subConns: make(map[resolver.Address]subConnInfo),
|
subConns: resolver.NewAddressMap(),
|
||||||
scStates: make(map[balancer.SubConn]connectivity.State),
|
scStates: make(map[balancer.SubConn]connectivity.State),
|
||||||
csEvltr: &balancer.ConnectivityStateEvaluator{},
|
csEvltr: &balancer.ConnectivityStateEvaluator{},
|
||||||
config: bb.config,
|
config: bb.config,
|
||||||
@ -58,11 +57,6 @@ func (bb *baseBuilder) Name() string {
|
|||||||
return bb.name
|
return bb.name
|
||||||
}
|
}
|
||||||
|
|
||||||
type subConnInfo struct {
|
|
||||||
subConn balancer.SubConn
|
|
||||||
attrs *attributes.Attributes
|
|
||||||
}
|
|
||||||
|
|
||||||
type baseBalancer struct {
|
type baseBalancer struct {
|
||||||
cc balancer.ClientConn
|
cc balancer.ClientConn
|
||||||
pickerBuilder PickerBuilder
|
pickerBuilder PickerBuilder
|
||||||
@ -70,7 +64,7 @@ type baseBalancer struct {
|
|||||||
csEvltr *balancer.ConnectivityStateEvaluator
|
csEvltr *balancer.ConnectivityStateEvaluator
|
||||||
state connectivity.State
|
state connectivity.State
|
||||||
|
|
||||||
subConns map[resolver.Address]subConnInfo // `attributes` is stripped from the keys of this map (the addresses)
|
subConns *resolver.AddressMap
|
||||||
scStates map[balancer.SubConn]connectivity.State
|
scStates map[balancer.SubConn]connectivity.State
|
||||||
picker balancer.Picker
|
picker balancer.Picker
|
||||||
config Config
|
config Config
|
||||||
@ -81,7 +75,7 @@ type baseBalancer struct {
|
|||||||
|
|
||||||
func (b *baseBalancer) ResolverError(err error) {
|
func (b *baseBalancer) ResolverError(err error) {
|
||||||
b.resolverErr = err
|
b.resolverErr = err
|
||||||
if len(b.subConns) == 0 {
|
if b.subConns.Len() == 0 {
|
||||||
b.state = connectivity.TransientFailure
|
b.state = connectivity.TransientFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,53 +99,29 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
|
|||||||
// Successful resolution; clear resolver error and ensure we return nil.
|
// Successful resolution; clear resolver error and ensure we return nil.
|
||||||
b.resolverErr = nil
|
b.resolverErr = nil
|
||||||
// addrsSet is the set converted from addrs, it's used for quick lookup of an address.
|
// addrsSet is the set converted from addrs, it's used for quick lookup of an address.
|
||||||
addrsSet := make(map[resolver.Address]struct{})
|
addrsSet := resolver.NewAddressMap()
|
||||||
for _, a := range s.ResolverState.Addresses {
|
for _, a := range s.ResolverState.Addresses {
|
||||||
// Strip attributes from addresses before using them as map keys. So
|
addrsSet.Set(a, nil)
|
||||||
// that when two addresses only differ in attributes pointers (but with
|
if _, ok := b.subConns.Get(a); !ok {
|
||||||
// the same attribute content), they are considered the same address.
|
|
||||||
//
|
|
||||||
// Note that this doesn't handle the case where the attribute content is
|
|
||||||
// different. So if users want to set different attributes to create
|
|
||||||
// duplicate connections to the same backend, it doesn't work. This is
|
|
||||||
// fine for now, because duplicate is done by setting Metadata today.
|
|
||||||
//
|
|
||||||
// TODO: read attributes to handle duplicate connections.
|
|
||||||
aNoAttrs := a
|
|
||||||
aNoAttrs.Attributes = nil
|
|
||||||
addrsSet[aNoAttrs] = struct{}{}
|
|
||||||
if scInfo, ok := b.subConns[aNoAttrs]; !ok {
|
|
||||||
// a is a new address (not existing in b.subConns).
|
// a is a new address (not existing in b.subConns).
|
||||||
//
|
|
||||||
// When creating SubConn, the original address with attributes is
|
|
||||||
// passed through. So that connection configurations in attributes
|
|
||||||
// (like creds) will be used.
|
|
||||||
sc, err := b.cc.NewSubConn([]resolver.Address{a}, balancer.NewSubConnOptions{HealthCheckEnabled: b.config.HealthCheck})
|
sc, err := b.cc.NewSubConn([]resolver.Address{a}, balancer.NewSubConnOptions{HealthCheckEnabled: b.config.HealthCheck})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warningf("base.baseBalancer: failed to create new SubConn: %v", err)
|
logger.Warningf("base.baseBalancer: failed to create new SubConn: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
b.subConns[aNoAttrs] = subConnInfo{subConn: sc, attrs: a.Attributes}
|
b.subConns.Set(a, sc)
|
||||||
b.scStates[sc] = connectivity.Idle
|
b.scStates[sc] = connectivity.Idle
|
||||||
b.csEvltr.RecordTransition(connectivity.Shutdown, connectivity.Idle)
|
b.csEvltr.RecordTransition(connectivity.Shutdown, connectivity.Idle)
|
||||||
sc.Connect()
|
sc.Connect()
|
||||||
} else {
|
|
||||||
// Always update the subconn's address in case the attributes
|
|
||||||
// changed.
|
|
||||||
//
|
|
||||||
// The SubConn does a reflect.DeepEqual of the new and old
|
|
||||||
// addresses. So this is a noop if the current address is the same
|
|
||||||
// as the old one (including attributes).
|
|
||||||
scInfo.attrs = a.Attributes
|
|
||||||
b.subConns[aNoAttrs] = scInfo
|
|
||||||
b.cc.UpdateAddresses(scInfo.subConn, []resolver.Address{a})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for a, scInfo := range b.subConns {
|
for _, a := range b.subConns.Keys() {
|
||||||
|
sci, _ := b.subConns.Get(a)
|
||||||
|
sc := sci.(balancer.SubConn)
|
||||||
// a was removed by resolver.
|
// a was removed by resolver.
|
||||||
if _, ok := addrsSet[a]; !ok {
|
if _, ok := addrsSet.Get(a); !ok {
|
||||||
b.cc.RemoveSubConn(scInfo.subConn)
|
b.cc.RemoveSubConn(sc)
|
||||||
delete(b.subConns, a)
|
b.subConns.Delete(a)
|
||||||
// Keep the state of this sc in b.scStates until sc's state becomes Shutdown.
|
// Keep the state of this sc in b.scStates until sc's state becomes Shutdown.
|
||||||
// The entry will be deleted in UpdateSubConnState.
|
// The entry will be deleted in UpdateSubConnState.
|
||||||
}
|
}
|
||||||
@ -193,10 +163,11 @@ func (b *baseBalancer) regeneratePicker() {
|
|||||||
readySCs := make(map[balancer.SubConn]SubConnInfo)
|
readySCs := make(map[balancer.SubConn]SubConnInfo)
|
||||||
|
|
||||||
// Filter out all ready SCs from full subConn map.
|
// Filter out all ready SCs from full subConn map.
|
||||||
for addr, scInfo := range b.subConns {
|
for _, addr := range b.subConns.Keys() {
|
||||||
if st, ok := b.scStates[scInfo.subConn]; ok && st == connectivity.Ready {
|
sci, _ := b.subConns.Get(addr)
|
||||||
addr.Attributes = scInfo.attrs
|
sc := sci.(balancer.SubConn)
|
||||||
readySCs[scInfo.subConn] = SubConnInfo{Address: addr}
|
if st, ok := b.scStates[sc]; ok && st == connectivity.Ready {
|
||||||
|
readySCs[sc] = SubConnInfo{Address: addr}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b.picker = b.pickerBuilder.Build(PickerBuildInfo{ReadySCs: readySCs})
|
b.picker = b.pickerBuilder.Build(PickerBuildInfo{ReadySCs: readySCs})
|
||||||
|
2
vendor/google.golang.org/grpc/balancer/grpclb/state/state.go
generated
vendored
2
vendor/google.golang.org/grpc/balancer/grpclb/state/state.go
generated
vendored
@ -39,7 +39,7 @@ type State struct {
|
|||||||
// Set returns a copy of the provided state with attributes containing s. s's
|
// Set returns a copy of the provided state with attributes containing s. s's
|
||||||
// data should not be mutated after calling Set.
|
// data should not be mutated after calling Set.
|
||||||
func Set(state resolver.State, s *State) resolver.State {
|
func Set(state resolver.State, s *State) resolver.State {
|
||||||
state.Attributes = state.Attributes.WithValues(key, s)
|
state.Attributes = state.Attributes.WithValue(key, s)
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
181
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
181
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
@ -23,6 +23,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -37,7 +38,6 @@ import (
|
|||||||
"google.golang.org/grpc/internal/backoff"
|
"google.golang.org/grpc/internal/backoff"
|
||||||
"google.golang.org/grpc/internal/channelz"
|
"google.golang.org/grpc/internal/channelz"
|
||||||
"google.golang.org/grpc/internal/grpcsync"
|
"google.golang.org/grpc/internal/grpcsync"
|
||||||
"google.golang.org/grpc/internal/grpcutil"
|
|
||||||
iresolver "google.golang.org/grpc/internal/resolver"
|
iresolver "google.golang.org/grpc/internal/resolver"
|
||||||
"google.golang.org/grpc/internal/transport"
|
"google.golang.org/grpc/internal/transport"
|
||||||
"google.golang.org/grpc/keepalive"
|
"google.golang.org/grpc/keepalive"
|
||||||
@ -248,38 +248,15 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine the resolver to use.
|
// Determine the resolver to use.
|
||||||
cc.parsedTarget = grpcutil.ParseTarget(cc.target, cc.dopts.copts.Dialer != nil)
|
resolverBuilder, err := cc.parseTargetAndFindResolver()
|
||||||
channelz.Infof(logger, cc.channelzID, "parsed scheme: %q", cc.parsedTarget.Scheme)
|
if err != nil {
|
||||||
resolverBuilder := cc.getResolver(cc.parsedTarget.Scheme)
|
return nil, err
|
||||||
if resolverBuilder == nil {
|
|
||||||
// If resolver builder is still nil, the parsed target's scheme is
|
|
||||||
// not registered. Fallback to default resolver and set Endpoint to
|
|
||||||
// the original target.
|
|
||||||
channelz.Infof(logger, cc.channelzID, "scheme %q not registered, fallback to default scheme", cc.parsedTarget.Scheme)
|
|
||||||
cc.parsedTarget = resolver.Target{
|
|
||||||
Scheme: resolver.GetDefaultScheme(),
|
|
||||||
Endpoint: target,
|
|
||||||
}
|
|
||||||
resolverBuilder = cc.getResolver(cc.parsedTarget.Scheme)
|
|
||||||
if resolverBuilder == nil {
|
|
||||||
return nil, fmt.Errorf("could not get resolver for default scheme: %q", cc.parsedTarget.Scheme)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
cc.authority, err = determineAuthority(cc.parsedTarget.Endpoint, cc.target, cc.dopts)
|
||||||
creds := cc.dopts.copts.TransportCredentials
|
if err != nil {
|
||||||
if creds != nil && creds.Info().ServerName != "" {
|
return nil, err
|
||||||
cc.authority = creds.Info().ServerName
|
|
||||||
} else if cc.dopts.insecure && cc.dopts.authority != "" {
|
|
||||||
cc.authority = cc.dopts.authority
|
|
||||||
} else if strings.HasPrefix(cc.target, "unix:") || strings.HasPrefix(cc.target, "unix-abstract:") {
|
|
||||||
cc.authority = "localhost"
|
|
||||||
} else if strings.HasPrefix(cc.parsedTarget.Endpoint, ":") {
|
|
||||||
cc.authority = "localhost" + cc.parsedTarget.Endpoint
|
|
||||||
} else {
|
|
||||||
// Use endpoint from "scheme://authority/endpoint" as the default
|
|
||||||
// authority for ClientConn.
|
|
||||||
cc.authority = cc.parsedTarget.Endpoint
|
|
||||||
}
|
}
|
||||||
|
channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority)
|
||||||
|
|
||||||
if cc.dopts.scChan != nil && !scSet {
|
if cc.dopts.scChan != nil && !scSet {
|
||||||
// Blocking wait for the initial service config.
|
// Blocking wait for the initial service config.
|
||||||
@ -902,10 +879,7 @@ func (ac *addrConn) tryUpdateAddrs(addrs []resolver.Address) bool {
|
|||||||
// ac.state is Ready, try to find the connected address.
|
// ac.state is Ready, try to find the connected address.
|
||||||
var curAddrFound bool
|
var curAddrFound bool
|
||||||
for _, a := range addrs {
|
for _, a := range addrs {
|
||||||
// a.ServerName takes precedent over ClientConn authority, if present.
|
a.ServerName = ac.cc.getServerName(a)
|
||||||
if a.ServerName == "" {
|
|
||||||
a.ServerName = ac.cc.authority
|
|
||||||
}
|
|
||||||
if reflect.DeepEqual(ac.curAddr, a) {
|
if reflect.DeepEqual(ac.curAddr, a) {
|
||||||
curAddrFound = true
|
curAddrFound = true
|
||||||
break
|
break
|
||||||
@ -919,6 +893,26 @@ func (ac *addrConn) tryUpdateAddrs(addrs []resolver.Address) bool {
|
|||||||
return curAddrFound
|
return curAddrFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getServerName determines the serverName to be used in the connection
|
||||||
|
// handshake. The default value for the serverName is the authority on the
|
||||||
|
// ClientConn, which either comes from the user's dial target or through an
|
||||||
|
// authority override specified using the WithAuthority dial option. Name
|
||||||
|
// resolvers can specify a per-address override for the serverName through the
|
||||||
|
// resolver.Address.ServerName field which is used only if the WithAuthority
|
||||||
|
// dial option was not used. The rationale is that per-address authority
|
||||||
|
// overrides specified by the name resolver can represent a security risk, while
|
||||||
|
// an override specified by the user is more dependable since they probably know
|
||||||
|
// what they are doing.
|
||||||
|
func (cc *ClientConn) getServerName(addr resolver.Address) string {
|
||||||
|
if cc.dopts.authority != "" {
|
||||||
|
return cc.dopts.authority
|
||||||
|
}
|
||||||
|
if addr.ServerName != "" {
|
||||||
|
return addr.ServerName
|
||||||
|
}
|
||||||
|
return cc.authority
|
||||||
|
}
|
||||||
|
|
||||||
func getMethodConfig(sc *ServiceConfig, method string) MethodConfig {
|
func getMethodConfig(sc *ServiceConfig, method string) MethodConfig {
|
||||||
if sc == nil {
|
if sc == nil {
|
||||||
return MethodConfig{}
|
return MethodConfig{}
|
||||||
@ -1275,11 +1269,7 @@ func (ac *addrConn) createTransport(addr resolver.Address, copts transport.Conne
|
|||||||
prefaceReceived := grpcsync.NewEvent()
|
prefaceReceived := grpcsync.NewEvent()
|
||||||
connClosed := grpcsync.NewEvent()
|
connClosed := grpcsync.NewEvent()
|
||||||
|
|
||||||
// addr.ServerName takes precedent over ClientConn authority, if present.
|
addr.ServerName = ac.cc.getServerName(addr)
|
||||||
if addr.ServerName == "" {
|
|
||||||
addr.ServerName = ac.cc.authority
|
|
||||||
}
|
|
||||||
|
|
||||||
hctx, hcancel := context.WithCancel(ac.ctx)
|
hctx, hcancel := context.WithCancel(ac.ctx)
|
||||||
hcStarted := false // protected by ac.mu
|
hcStarted := false // protected by ac.mu
|
||||||
|
|
||||||
@ -1621,3 +1611,114 @@ func (cc *ClientConn) connectionError() error {
|
|||||||
defer cc.lceMu.Unlock()
|
defer cc.lceMu.Unlock()
|
||||||
return cc.lastConnectionError
|
return cc.lastConnectionError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cc *ClientConn) parseTargetAndFindResolver() (resolver.Builder, error) {
|
||||||
|
channelz.Infof(logger, cc.channelzID, "original dial target is: %q", cc.target)
|
||||||
|
|
||||||
|
var rb resolver.Builder
|
||||||
|
parsedTarget, err := parseTarget(cc.target)
|
||||||
|
if err != nil {
|
||||||
|
channelz.Infof(logger, cc.channelzID, "dial target %q parse failed: %v", cc.target, err)
|
||||||
|
} else {
|
||||||
|
channelz.Infof(logger, cc.channelzID, "parsed dial target is: %+v", parsedTarget)
|
||||||
|
rb = cc.getResolver(parsedTarget.Scheme)
|
||||||
|
if rb != nil {
|
||||||
|
cc.parsedTarget = parsedTarget
|
||||||
|
return rb, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We are here because the user's dial target did not contain a scheme or
|
||||||
|
// specified an unregistered scheme. We should fallback to the default
|
||||||
|
// scheme, except when a custom dialer is specified in which case, we should
|
||||||
|
// always use passthrough scheme.
|
||||||
|
defScheme := resolver.GetDefaultScheme()
|
||||||
|
channelz.Infof(logger, cc.channelzID, "fallback to scheme %q", defScheme)
|
||||||
|
canonicalTarget := defScheme + ":///" + cc.target
|
||||||
|
|
||||||
|
parsedTarget, err = parseTarget(canonicalTarget)
|
||||||
|
if err != nil {
|
||||||
|
channelz.Infof(logger, cc.channelzID, "dial target %q parse failed: %v", canonicalTarget, err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
channelz.Infof(logger, cc.channelzID, "parsed dial target is: %+v", parsedTarget)
|
||||||
|
rb = cc.getResolver(parsedTarget.Scheme)
|
||||||
|
if rb == nil {
|
||||||
|
return nil, fmt.Errorf("could not get resolver for default scheme: %q", parsedTarget.Scheme)
|
||||||
|
}
|
||||||
|
cc.parsedTarget = parsedTarget
|
||||||
|
return rb, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseTarget uses RFC 3986 semantics to parse the given target into a
|
||||||
|
// resolver.Target struct containing scheme, authority and endpoint. Query
|
||||||
|
// params are stripped from the endpoint.
|
||||||
|
func parseTarget(target string) (resolver.Target, error) {
|
||||||
|
u, err := url.Parse(target)
|
||||||
|
if err != nil {
|
||||||
|
return resolver.Target{}, err
|
||||||
|
}
|
||||||
|
// For targets of the form "[scheme]://[authority]/endpoint, the endpoint
|
||||||
|
// value returned from url.Parse() contains a leading "/". Although this is
|
||||||
|
// in accordance with RFC 3986, we do not want to break existing resolver
|
||||||
|
// implementations which expect the endpoint without the leading "/". So, we
|
||||||
|
// end up stripping the leading "/" here. But this will result in an
|
||||||
|
// incorrect parsing for something like "unix:///path/to/socket". Since we
|
||||||
|
// own the "unix" resolver, we can workaround in the unix resolver by using
|
||||||
|
// the `URL` field instead of the `Endpoint` field.
|
||||||
|
endpoint := u.Path
|
||||||
|
if endpoint == "" {
|
||||||
|
endpoint = u.Opaque
|
||||||
|
}
|
||||||
|
endpoint = strings.TrimPrefix(endpoint, "/")
|
||||||
|
return resolver.Target{
|
||||||
|
Scheme: u.Scheme,
|
||||||
|
Authority: u.Host,
|
||||||
|
Endpoint: endpoint,
|
||||||
|
URL: *u,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine channel authority. The order of precedence is as follows:
|
||||||
|
// - user specified authority override using `WithAuthority` dial option
|
||||||
|
// - creds' notion of server name for the authentication handshake
|
||||||
|
// - endpoint from dial target of the form "scheme://[authority]/endpoint"
|
||||||
|
func determineAuthority(endpoint, target string, dopts dialOptions) (string, error) {
|
||||||
|
// Historically, we had two options for users to specify the serverName or
|
||||||
|
// authority for a channel. One was through the transport credentials
|
||||||
|
// (either in its constructor, or through the OverrideServerName() method).
|
||||||
|
// The other option (for cases where WithInsecure() dial option was used)
|
||||||
|
// was to use the WithAuthority() dial option.
|
||||||
|
//
|
||||||
|
// A few things have changed since:
|
||||||
|
// - `insecure` package with an implementation of the `TransportCredentials`
|
||||||
|
// interface for the insecure case
|
||||||
|
// - WithAuthority() dial option support for secure credentials
|
||||||
|
authorityFromCreds := ""
|
||||||
|
if creds := dopts.copts.TransportCredentials; creds != nil && creds.Info().ServerName != "" {
|
||||||
|
authorityFromCreds = creds.Info().ServerName
|
||||||
|
}
|
||||||
|
authorityFromDialOption := dopts.authority
|
||||||
|
if (authorityFromCreds != "" && authorityFromDialOption != "") && authorityFromCreds != authorityFromDialOption {
|
||||||
|
return "", fmt.Errorf("ClientConn's authority from transport creds %q and dial option %q don't match", authorityFromCreds, authorityFromDialOption)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case authorityFromDialOption != "":
|
||||||
|
return authorityFromDialOption, nil
|
||||||
|
case authorityFromCreds != "":
|
||||||
|
return authorityFromCreds, nil
|
||||||
|
case strings.HasPrefix(target, "unix:") || strings.HasPrefix(target, "unix-abstract:"):
|
||||||
|
// TODO: remove when the unix resolver implements optional interface to
|
||||||
|
// return channel authority.
|
||||||
|
return "localhost", nil
|
||||||
|
case strings.HasPrefix(endpoint, ":"):
|
||||||
|
return "localhost" + endpoint, nil
|
||||||
|
default:
|
||||||
|
// TODO: Define an optional interface on the resolver builder to return
|
||||||
|
// the channel authority given the user's dial target. For resolvers
|
||||||
|
// which don't implement this interface, we will use the endpoint from
|
||||||
|
// "scheme://authority/endpoint" as the default authority.
|
||||||
|
return endpoint, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
15
vendor/google.golang.org/grpc/credentials/credentials.go
generated
vendored
15
vendor/google.golang.org/grpc/credentials/credentials.go
generated
vendored
@ -140,6 +140,11 @@ type TransportCredentials interface {
|
|||||||
// Additionally, ClientHandshakeInfo data will be available via the context
|
// Additionally, ClientHandshakeInfo data will be available via the context
|
||||||
// passed to this call.
|
// passed to this call.
|
||||||
//
|
//
|
||||||
|
// The second argument to this method is the `:authority` header value used
|
||||||
|
// while creating new streams on this connection after authentication
|
||||||
|
// succeeds. Implementations must use this as the server name during the
|
||||||
|
// authentication handshake.
|
||||||
|
//
|
||||||
// If the returned net.Conn is closed, it MUST close the net.Conn provided.
|
// If the returned net.Conn is closed, it MUST close the net.Conn provided.
|
||||||
ClientHandshake(context.Context, string, net.Conn) (net.Conn, AuthInfo, error)
|
ClientHandshake(context.Context, string, net.Conn) (net.Conn, AuthInfo, error)
|
||||||
// ServerHandshake does the authentication handshake for servers. It returns
|
// ServerHandshake does the authentication handshake for servers. It returns
|
||||||
@ -153,9 +158,13 @@ type TransportCredentials interface {
|
|||||||
Info() ProtocolInfo
|
Info() ProtocolInfo
|
||||||
// Clone makes a copy of this TransportCredentials.
|
// Clone makes a copy of this TransportCredentials.
|
||||||
Clone() TransportCredentials
|
Clone() TransportCredentials
|
||||||
// OverrideServerName overrides the server name used to verify the hostname on the returned certificates from the server.
|
// OverrideServerName specifies the value used for the following:
|
||||||
// gRPC internals also use it to override the virtual hosting name if it is set.
|
// - verifying the hostname on the returned certificates
|
||||||
// It must be called before dialing. Currently, this is only used by grpclb.
|
// - as SNI in the client's handshake to support virtual hosting
|
||||||
|
// - as the value for `:authority` header at stream creation time
|
||||||
|
//
|
||||||
|
// Deprecated: use grpc.WithAuthority instead. Will be supported
|
||||||
|
// throughout 1.x.
|
||||||
OverrideServerName(string) error
|
OverrideServerName(string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
vendor/google.golang.org/grpc/dialoptions.go
generated
vendored
27
vendor/google.golang.org/grpc/dialoptions.go
generated
vendored
@ -482,8 +482,7 @@ func WithChainStreamInterceptor(interceptors ...StreamClientInterceptor) DialOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithAuthority returns a DialOption that specifies the value to be used as the
|
// WithAuthority returns a DialOption that specifies the value to be used as the
|
||||||
// :authority pseudo-header. This value only works with WithInsecure and has no
|
// :authority pseudo-header and as the server name in authentication handshake.
|
||||||
// effect if TransportCredentials are present.
|
|
||||||
func WithAuthority(a string) DialOption {
|
func WithAuthority(a string) DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
o.authority = a
|
o.authority = a
|
||||||
@ -519,14 +518,16 @@ func WithDisableServiceConfig() DialOption {
|
|||||||
// WithDefaultServiceConfig returns a DialOption that configures the default
|
// WithDefaultServiceConfig returns a DialOption that configures the default
|
||||||
// service config, which will be used in cases where:
|
// service config, which will be used in cases where:
|
||||||
//
|
//
|
||||||
// 1. WithDisableServiceConfig is also used.
|
// 1. WithDisableServiceConfig is also used, or
|
||||||
// 2. Resolver does not return a service config or if the resolver returns an
|
|
||||||
// invalid service config.
|
|
||||||
//
|
//
|
||||||
// Experimental
|
// 2. The name resolver does not provide a service config or provides an
|
||||||
|
// invalid service config.
|
||||||
//
|
//
|
||||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
// The parameter s is the JSON representation of the default service config.
|
||||||
// later release.
|
// For more information about service configs, see:
|
||||||
|
// https://github.com/grpc/grpc/blob/master/doc/service_config.md
|
||||||
|
// For a simple example of usage, see:
|
||||||
|
// examples/features/load_balancing/client/main.go
|
||||||
func WithDefaultServiceConfig(s string) DialOption {
|
func WithDefaultServiceConfig(s string) DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
o.defaultServiceConfigRawJSON = &s
|
o.defaultServiceConfigRawJSON = &s
|
||||||
@ -538,14 +539,8 @@ func WithDefaultServiceConfig(s string) DialOption {
|
|||||||
// will happen automatically if no data is written to the wire or if the RPC is
|
// will happen automatically if no data is written to the wire or if the RPC is
|
||||||
// unprocessed by the remote server.
|
// unprocessed by the remote server.
|
||||||
//
|
//
|
||||||
// Retry support is currently disabled by default, but will be enabled by
|
// Retry support is currently enabled by default, but may be disabled by
|
||||||
// default in the future. Until then, it may be enabled by setting the
|
// setting the environment variable "GRPC_GO_RETRY" to "off".
|
||||||
// environment variable "GRPC_GO_RETRY" to "on".
|
|
||||||
//
|
|
||||||
// Experimental
|
|
||||||
//
|
|
||||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
|
||||||
// later release.
|
|
||||||
func WithDisableRetry() DialOption {
|
func WithDisableRetry() DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
o.disableRetry = true
|
o.disableRetry = true
|
||||||
|
3
vendor/google.golang.org/grpc/go.mod
generated
vendored
3
vendor/google.golang.org/grpc/go.mod
generated
vendored
@ -4,7 +4,8 @@ go 1.14
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cespare/xxhash/v2 v2.1.1
|
github.com/cespare/xxhash/v2 v2.1.1
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403
|
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4
|
||||||
|
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1
|
||||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021
|
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||||
github.com/golang/protobuf v1.4.3
|
github.com/golang/protobuf v1.4.3
|
||||||
|
7
vendor/google.golang.org/grpc/go.sum
generated
vendored
7
vendor/google.golang.org/grpc/go.sum
generated
vendored
@ -9,10 +9,13 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+
|
|||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M=
|
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158 h1:CevA8fI91PAnP8vpnXuB8ZYAZ5wqY86nAbxfgK8tWO4=
|
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 h1:hzAQntlaYRkVSFEfj9OTWlVV1H155FMD8BTKktLv0QI=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 h1:zH8ljVhhq7yC0MIeUL/IviMtY8hx2mK8cN9wEYb8ggw=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
86
vendor/google.golang.org/grpc/grpclog/loggerv2.go
generated
vendored
86
vendor/google.golang.org/grpc/grpclog/loggerv2.go
generated
vendored
@ -19,11 +19,14 @@
|
|||||||
package grpclog
|
package grpclog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"google.golang.org/grpc/internal/grpclog"
|
"google.golang.org/grpc/internal/grpclog"
|
||||||
)
|
)
|
||||||
@ -95,8 +98,9 @@ var severityName = []string{
|
|||||||
|
|
||||||
// loggerT is the default logger used by grpclog.
|
// loggerT is the default logger used by grpclog.
|
||||||
type loggerT struct {
|
type loggerT struct {
|
||||||
m []*log.Logger
|
m []*log.Logger
|
||||||
v int
|
v int
|
||||||
|
jsonFormat bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLoggerV2 creates a loggerV2 with the provided writers.
|
// NewLoggerV2 creates a loggerV2 with the provided writers.
|
||||||
@ -105,19 +109,32 @@ type loggerT struct {
|
|||||||
// Warning logs will be written to warningW and infoW.
|
// Warning logs will be written to warningW and infoW.
|
||||||
// Info logs will be written to infoW.
|
// Info logs will be written to infoW.
|
||||||
func NewLoggerV2(infoW, warningW, errorW io.Writer) LoggerV2 {
|
func NewLoggerV2(infoW, warningW, errorW io.Writer) LoggerV2 {
|
||||||
return NewLoggerV2WithVerbosity(infoW, warningW, errorW, 0)
|
return newLoggerV2WithConfig(infoW, warningW, errorW, loggerV2Config{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLoggerV2WithVerbosity creates a loggerV2 with the provided writers and
|
// NewLoggerV2WithVerbosity creates a loggerV2 with the provided writers and
|
||||||
// verbosity level.
|
// verbosity level.
|
||||||
func NewLoggerV2WithVerbosity(infoW, warningW, errorW io.Writer, v int) LoggerV2 {
|
func NewLoggerV2WithVerbosity(infoW, warningW, errorW io.Writer, v int) LoggerV2 {
|
||||||
|
return newLoggerV2WithConfig(infoW, warningW, errorW, loggerV2Config{verbose: v})
|
||||||
|
}
|
||||||
|
|
||||||
|
type loggerV2Config struct {
|
||||||
|
verbose int
|
||||||
|
jsonFormat bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func newLoggerV2WithConfig(infoW, warningW, errorW io.Writer, c loggerV2Config) LoggerV2 {
|
||||||
var m []*log.Logger
|
var m []*log.Logger
|
||||||
m = append(m, log.New(infoW, severityName[infoLog]+": ", log.LstdFlags))
|
flag := log.LstdFlags
|
||||||
m = append(m, log.New(io.MultiWriter(infoW, warningW), severityName[warningLog]+": ", log.LstdFlags))
|
if c.jsonFormat {
|
||||||
|
flag = 0
|
||||||
|
}
|
||||||
|
m = append(m, log.New(infoW, "", flag))
|
||||||
|
m = append(m, log.New(io.MultiWriter(infoW, warningW), "", flag))
|
||||||
ew := io.MultiWriter(infoW, warningW, errorW) // ew will be used for error and fatal.
|
ew := io.MultiWriter(infoW, warningW, errorW) // ew will be used for error and fatal.
|
||||||
m = append(m, log.New(ew, severityName[errorLog]+": ", log.LstdFlags))
|
m = append(m, log.New(ew, "", flag))
|
||||||
m = append(m, log.New(ew, severityName[fatalLog]+": ", log.LstdFlags))
|
m = append(m, log.New(ew, "", flag))
|
||||||
return &loggerT{m: m, v: v}
|
return &loggerT{m: m, v: c.verbose, jsonFormat: c.jsonFormat}
|
||||||
}
|
}
|
||||||
|
|
||||||
// newLoggerV2 creates a loggerV2 to be used as default logger.
|
// newLoggerV2 creates a loggerV2 to be used as default logger.
|
||||||
@ -142,58 +159,79 @@ func newLoggerV2() LoggerV2 {
|
|||||||
if vl, err := strconv.Atoi(vLevel); err == nil {
|
if vl, err := strconv.Atoi(vLevel); err == nil {
|
||||||
v = vl
|
v = vl
|
||||||
}
|
}
|
||||||
return NewLoggerV2WithVerbosity(infoW, warningW, errorW, v)
|
|
||||||
|
jsonFormat := strings.EqualFold(os.Getenv("GRPC_GO_LOG_FORMATTER"), "json")
|
||||||
|
|
||||||
|
return newLoggerV2WithConfig(infoW, warningW, errorW, loggerV2Config{
|
||||||
|
verbose: v,
|
||||||
|
jsonFormat: jsonFormat,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *loggerT) output(severity int, s string) {
|
||||||
|
sevStr := severityName[severity]
|
||||||
|
if !g.jsonFormat {
|
||||||
|
g.m[severity].Output(2, fmt.Sprintf("%v: %v", sevStr, s))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// TODO: we can also include the logging component, but that needs more
|
||||||
|
// (API) changes.
|
||||||
|
b, _ := json.Marshal(map[string]string{
|
||||||
|
"severity": sevStr,
|
||||||
|
"message": s,
|
||||||
|
})
|
||||||
|
g.m[severity].Output(2, string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Info(args ...interface{}) {
|
func (g *loggerT) Info(args ...interface{}) {
|
||||||
g.m[infoLog].Print(args...)
|
g.output(infoLog, fmt.Sprint(args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Infoln(args ...interface{}) {
|
func (g *loggerT) Infoln(args ...interface{}) {
|
||||||
g.m[infoLog].Println(args...)
|
g.output(infoLog, fmt.Sprintln(args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Infof(format string, args ...interface{}) {
|
func (g *loggerT) Infof(format string, args ...interface{}) {
|
||||||
g.m[infoLog].Printf(format, args...)
|
g.output(infoLog, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Warning(args ...interface{}) {
|
func (g *loggerT) Warning(args ...interface{}) {
|
||||||
g.m[warningLog].Print(args...)
|
g.output(warningLog, fmt.Sprint(args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Warningln(args ...interface{}) {
|
func (g *loggerT) Warningln(args ...interface{}) {
|
||||||
g.m[warningLog].Println(args...)
|
g.output(warningLog, fmt.Sprintln(args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Warningf(format string, args ...interface{}) {
|
func (g *loggerT) Warningf(format string, args ...interface{}) {
|
||||||
g.m[warningLog].Printf(format, args...)
|
g.output(warningLog, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Error(args ...interface{}) {
|
func (g *loggerT) Error(args ...interface{}) {
|
||||||
g.m[errorLog].Print(args...)
|
g.output(errorLog, fmt.Sprint(args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Errorln(args ...interface{}) {
|
func (g *loggerT) Errorln(args ...interface{}) {
|
||||||
g.m[errorLog].Println(args...)
|
g.output(errorLog, fmt.Sprintln(args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Errorf(format string, args ...interface{}) {
|
func (g *loggerT) Errorf(format string, args ...interface{}) {
|
||||||
g.m[errorLog].Printf(format, args...)
|
g.output(errorLog, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Fatal(args ...interface{}) {
|
func (g *loggerT) Fatal(args ...interface{}) {
|
||||||
g.m[fatalLog].Fatal(args...)
|
g.output(fatalLog, fmt.Sprint(args...))
|
||||||
// No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Fatalln(args ...interface{}) {
|
func (g *loggerT) Fatalln(args ...interface{}) {
|
||||||
g.m[fatalLog].Fatalln(args...)
|
g.output(fatalLog, fmt.Sprintln(args...))
|
||||||
// No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) Fatalf(format string, args ...interface{}) {
|
func (g *loggerT) Fatalf(format string, args ...interface{}) {
|
||||||
g.m[fatalLog].Fatalf(format, args...)
|
g.output(fatalLog, fmt.Sprintf(format, args...))
|
||||||
// No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *loggerT) V(l int) bool {
|
func (g *loggerT) V(l int) bool {
|
||||||
|
5
vendor/google.golang.org/grpc/internal/envconfig/envconfig.go
generated
vendored
5
vendor/google.golang.org/grpc/internal/envconfig/envconfig.go
generated
vendored
@ -33,8 +33,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Retry is set if retry is explicitly enabled via "GRPC_GO_RETRY=on" or if XDS retry support is enabled.
|
// Retry is enabled unless explicitly disabled via "GRPC_GO_RETRY=off" or
|
||||||
Retry = strings.EqualFold(os.Getenv(retryStr), "on") || xdsenv.RetrySupport
|
// if XDS retry support is explicitly disabled.
|
||||||
|
Retry = !strings.EqualFold(os.Getenv(retryStr), "off") && xdsenv.RetrySupport
|
||||||
// TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false").
|
// TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false").
|
||||||
TXTErrIgnore = !strings.EqualFold(os.Getenv(txtErrIgnoreStr), "false")
|
TXTErrIgnore = !strings.EqualFold(os.Getenv(txtErrIgnoreStr), "false")
|
||||||
)
|
)
|
||||||
|
20
vendor/google.golang.org/grpc/internal/grpcutil/grpcutil.go
generated
vendored
Normal file
20
vendor/google.golang.org/grpc/internal/grpcutil/grpcutil.go
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2021 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 grpcutil provides utility functions used across the gRPC codebase.
|
||||||
|
package grpcutil
|
28
vendor/google.golang.org/grpc/internal/grpcutil/regex.go
generated
vendored
Normal file
28
vendor/google.golang.org/grpc/internal/grpcutil/regex.go
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2021 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 grpcutil
|
||||||
|
|
||||||
|
import "regexp"
|
||||||
|
|
||||||
|
// FullMatchWithRegex returns whether the full string matches the regex provided.
|
||||||
|
func FullMatchWithRegex(re *regexp.Regexp, string string) bool {
|
||||||
|
re.Longest()
|
||||||
|
rem := re.FindString(string)
|
||||||
|
return len(rem) == len(string)
|
||||||
|
}
|
89
vendor/google.golang.org/grpc/internal/grpcutil/target.go
generated
vendored
89
vendor/google.golang.org/grpc/internal/grpcutil/target.go
generated
vendored
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2020 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 grpcutil provides a bunch of utility functions to be used across the
|
|
||||||
// gRPC codebase.
|
|
||||||
package grpcutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"google.golang.org/grpc/resolver"
|
|
||||||
)
|
|
||||||
|
|
||||||
// split2 returns the values from strings.SplitN(s, sep, 2).
|
|
||||||
// If sep is not found, it returns ("", "", false) instead.
|
|
||||||
func split2(s, sep string) (string, string, bool) {
|
|
||||||
spl := strings.SplitN(s, sep, 2)
|
|
||||||
if len(spl) < 2 {
|
|
||||||
return "", "", false
|
|
||||||
}
|
|
||||||
return spl[0], spl[1], true
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseTarget splits target into a resolver.Target struct containing scheme,
|
|
||||||
// authority and endpoint. skipUnixColonParsing indicates that the parse should
|
|
||||||
// not parse "unix:[path]" cases. This should be true in cases where a custom
|
|
||||||
// dialer is present, to prevent a behavior change.
|
|
||||||
//
|
|
||||||
// If target is not a valid scheme://authority/endpoint as specified in
|
|
||||||
// https://github.com/grpc/grpc/blob/master/doc/naming.md,
|
|
||||||
// it returns {Endpoint: target}.
|
|
||||||
func ParseTarget(target string, skipUnixColonParsing bool) (ret resolver.Target) {
|
|
||||||
var ok bool
|
|
||||||
if strings.HasPrefix(target, "unix-abstract:") {
|
|
||||||
if strings.HasPrefix(target, "unix-abstract://") {
|
|
||||||
// Maybe, with Authority specified, try to parse it
|
|
||||||
var remain string
|
|
||||||
ret.Scheme, remain, _ = split2(target, "://")
|
|
||||||
ret.Authority, ret.Endpoint, ok = split2(remain, "/")
|
|
||||||
if !ok {
|
|
||||||
// No Authority, add the "//" back
|
|
||||||
ret.Endpoint = "//" + remain
|
|
||||||
} else {
|
|
||||||
// Found Authority, add the "/" back
|
|
||||||
ret.Endpoint = "/" + ret.Endpoint
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Without Authority specified, split target on ":"
|
|
||||||
ret.Scheme, ret.Endpoint, _ = split2(target, ":")
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
ret.Scheme, ret.Endpoint, ok = split2(target, "://")
|
|
||||||
if !ok {
|
|
||||||
if strings.HasPrefix(target, "unix:") && !skipUnixColonParsing {
|
|
||||||
// Handle the "unix:[local/path]" and "unix:[/absolute/path]" cases,
|
|
||||||
// because splitting on :// only handles the
|
|
||||||
// "unix://[/absolute/path]" case. Only handle if the dialer is nil,
|
|
||||||
// to avoid a behavior change with custom dialers.
|
|
||||||
return resolver.Target{Scheme: "unix", Endpoint: target[len("unix:"):]}
|
|
||||||
}
|
|
||||||
return resolver.Target{Endpoint: target}
|
|
||||||
}
|
|
||||||
ret.Authority, ret.Endpoint, ok = split2(ret.Endpoint, "/")
|
|
||||||
if !ok {
|
|
||||||
return resolver.Target{Endpoint: target}
|
|
||||||
}
|
|
||||||
if ret.Scheme == "unix" {
|
|
||||||
// Add the "/" back in the unix case, so the unix resolver receives the
|
|
||||||
// actual endpoint in the "unix://[/absolute/path]" case.
|
|
||||||
ret.Endpoint = "/" + ret.Endpoint
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
30
vendor/google.golang.org/grpc/internal/metadata/metadata.go
generated
vendored
30
vendor/google.golang.org/grpc/internal/metadata/metadata.go
generated
vendored
@ -30,14 +30,38 @@ type mdKeyType string
|
|||||||
|
|
||||||
const mdKey = mdKeyType("grpc.internal.address.metadata")
|
const mdKey = mdKeyType("grpc.internal.address.metadata")
|
||||||
|
|
||||||
|
type mdValue metadata.MD
|
||||||
|
|
||||||
|
func (m mdValue) Equal(o interface{}) bool {
|
||||||
|
om, ok := o.(mdValue)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(m) != len(om) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for k, v := range m {
|
||||||
|
ov := om[k]
|
||||||
|
if len(ov) != len(v) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for i, ve := range v {
|
||||||
|
if ov[i] != ve {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Get returns the metadata of addr.
|
// Get returns the metadata of addr.
|
||||||
func Get(addr resolver.Address) metadata.MD {
|
func Get(addr resolver.Address) metadata.MD {
|
||||||
attrs := addr.Attributes
|
attrs := addr.Attributes
|
||||||
if attrs == nil {
|
if attrs == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
md, _ := attrs.Value(mdKey).(metadata.MD)
|
md, _ := attrs.Value(mdKey).(mdValue)
|
||||||
return md
|
return metadata.MD(md)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set sets (overrides) the metadata in addr.
|
// Set sets (overrides) the metadata in addr.
|
||||||
@ -45,6 +69,6 @@ func Get(addr resolver.Address) metadata.MD {
|
|||||||
// When a SubConn is created with this address, the RPCs sent on it will all
|
// When a SubConn is created with this address, the RPCs sent on it will all
|
||||||
// have this metadata.
|
// have this metadata.
|
||||||
func Set(addr resolver.Address, md metadata.MD) resolver.Address {
|
func Set(addr resolver.Address, md metadata.MD) resolver.Address {
|
||||||
addr.Attributes = addr.Attributes.WithValues(mdKey, md)
|
addr.Attributes = addr.Attributes.WithValue(mdKey, mdValue(md))
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
2
vendor/google.golang.org/grpc/internal/resolver/config_selector.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/resolver/config_selector.go
generated
vendored
@ -132,7 +132,7 @@ const csKey = csKeyType("grpc.internal.resolver.configSelector")
|
|||||||
// SetConfigSelector sets the config selector in state and returns the new
|
// SetConfigSelector sets the config selector in state and returns the new
|
||||||
// state.
|
// state.
|
||||||
func SetConfigSelector(state resolver.State, cs ConfigSelector) resolver.State {
|
func SetConfigSelector(state resolver.State, cs ConfigSelector) resolver.State {
|
||||||
state.Attributes = state.Attributes.WithValues(csKey, cs)
|
state.Attributes = state.Attributes.WithValue(csKey, cs)
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
vendor/google.golang.org/grpc/internal/resolver/unix/unix.go
generated
vendored
12
vendor/google.golang.org/grpc/internal/resolver/unix/unix.go
generated
vendored
@ -37,7 +37,17 @@ func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, _ resolv
|
|||||||
if target.Authority != "" {
|
if target.Authority != "" {
|
||||||
return nil, fmt.Errorf("invalid (non-empty) authority: %v", target.Authority)
|
return nil, fmt.Errorf("invalid (non-empty) authority: %v", target.Authority)
|
||||||
}
|
}
|
||||||
addr := resolver.Address{Addr: target.Endpoint}
|
|
||||||
|
// gRPC was parsing the dial target manually before PR #4817, and we
|
||||||
|
// switched to using url.Parse() in that PR. To avoid breaking existing
|
||||||
|
// resolver implementations we ended up stripping the leading "/" from the
|
||||||
|
// endpoint. This obviously does not work for the "unix" scheme. Hence we
|
||||||
|
// end up using the parsed URL instead.
|
||||||
|
endpoint := target.URL.Path
|
||||||
|
if endpoint == "" {
|
||||||
|
endpoint = target.URL.Opaque
|
||||||
|
}
|
||||||
|
addr := resolver.Address{Addr: endpoint}
|
||||||
if b.scheme == unixAbstractScheme {
|
if b.scheme == unixAbstractScheme {
|
||||||
// prepend "\x00" to address for unix-abstract
|
// prepend "\x00" to address for unix-abstract
|
||||||
addr.Addr = "\x00" + addr.Addr
|
addr.Addr = "\x00" + addr.Addr
|
||||||
|
8
vendor/google.golang.org/grpc/internal/transport/controlbuf.go
generated
vendored
8
vendor/google.golang.org/grpc/internal/transport/controlbuf.go
generated
vendored
@ -133,6 +133,7 @@ type cleanupStream struct {
|
|||||||
func (c *cleanupStream) isTransportResponseFrame() bool { return c.rst } // Results in a RST_STREAM
|
func (c *cleanupStream) isTransportResponseFrame() bool { return c.rst } // Results in a RST_STREAM
|
||||||
|
|
||||||
type earlyAbortStream struct {
|
type earlyAbortStream struct {
|
||||||
|
httpStatus uint32
|
||||||
streamID uint32
|
streamID uint32
|
||||||
contentSubtype string
|
contentSubtype string
|
||||||
status *status.Status
|
status *status.Status
|
||||||
@ -771,9 +772,12 @@ func (l *loopyWriter) earlyAbortStreamHandler(eas *earlyAbortStream) error {
|
|||||||
if l.side == clientSide {
|
if l.side == clientSide {
|
||||||
return errors.New("earlyAbortStream not handled on client")
|
return errors.New("earlyAbortStream not handled on client")
|
||||||
}
|
}
|
||||||
|
// In case the caller forgets to set the http status, default to 200.
|
||||||
|
if eas.httpStatus == 0 {
|
||||||
|
eas.httpStatus = 200
|
||||||
|
}
|
||||||
headerFields := []hpack.HeaderField{
|
headerFields := []hpack.HeaderField{
|
||||||
{Name: ":status", Value: "200"},
|
{Name: ":status", Value: strconv.Itoa(int(eas.httpStatus))},
|
||||||
{Name: "content-type", Value: grpcutil.ContentType(eas.contentSubtype)},
|
{Name: "content-type", Value: grpcutil.ContentType(eas.contentSubtype)},
|
||||||
{Name: "grpc-status", Value: strconv.Itoa(int(eas.status.Code()))},
|
{Name: "grpc-status", Value: strconv.Itoa(int(eas.status.Code()))},
|
||||||
{Name: "grpc-message", Value: encodeGrpcMessage(eas.status.Message())},
|
{Name: "grpc-message", Value: encodeGrpcMessage(eas.status.Message())},
|
||||||
|
61
vendor/google.golang.org/grpc/internal/transport/http2_client.go
generated
vendored
61
vendor/google.golang.org/grpc/internal/transport/http2_client.go
generated
vendored
@ -25,6 +25,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -146,13 +147,20 @@ func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error
|
|||||||
address := addr.Addr
|
address := addr.Addr
|
||||||
networkType, ok := networktype.Get(addr)
|
networkType, ok := networktype.Get(addr)
|
||||||
if fn != nil {
|
if fn != nil {
|
||||||
|
// Special handling for unix scheme with custom dialer. Back in the day,
|
||||||
|
// we did not have a unix resolver and therefore targets with a unix
|
||||||
|
// scheme would end up using the passthrough resolver. So, user's used a
|
||||||
|
// custom dialer in this case and expected the original dial target to
|
||||||
|
// be passed to the custom dialer. Now, we have a unix resolver. But if
|
||||||
|
// a custom dialer is specified, we want to retain the old behavior in
|
||||||
|
// terms of the address being passed to the custom dialer.
|
||||||
if networkType == "unix" && !strings.HasPrefix(address, "\x00") {
|
if networkType == "unix" && !strings.HasPrefix(address, "\x00") {
|
||||||
// For backward compatibility, if the user dialed "unix:///path",
|
// Supported unix targets are either "unix://absolute-path" or
|
||||||
// the passthrough resolver would be used and the user's custom
|
// "unix:relative-path".
|
||||||
// dialer would see "unix:///path". Since the unix resolver is used
|
if filepath.IsAbs(address) {
|
||||||
// and the address is now "/path", prepend "unix://" so the user's
|
return fn(ctx, "unix://"+address)
|
||||||
// custom dialer sees the same address.
|
}
|
||||||
return fn(ctx, "unix://"+address)
|
return fn(ctx, "unix:"+address)
|
||||||
}
|
}
|
||||||
return fn(ctx, address)
|
return fn(ctx, address)
|
||||||
}
|
}
|
||||||
@ -1073,7 +1081,7 @@ func (t *http2Client) handleData(f *http2.DataFrame) {
|
|||||||
}
|
}
|
||||||
// The server has closed the stream without sending trailers. Record that
|
// The server has closed the stream without sending trailers. Record that
|
||||||
// the read direction is closed, and set the status appropriately.
|
// the read direction is closed, and set the status appropriately.
|
||||||
if f.FrameHeader.Flags.Has(http2.FlagDataEndStream) {
|
if f.StreamEnded() {
|
||||||
t.closeStream(s, io.EOF, false, http2.ErrCodeNo, status.New(codes.Internal, "server closed the stream without sending trailers"), nil, true)
|
t.closeStream(s, io.EOF, false, http2.ErrCodeNo, status.New(codes.Internal, "server closed the stream without sending trailers"), nil, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1403,26 +1411,6 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isHeader := false
|
isHeader := false
|
||||||
defer func() {
|
|
||||||
if t.statsHandler != nil {
|
|
||||||
if isHeader {
|
|
||||||
inHeader := &stats.InHeader{
|
|
||||||
Client: true,
|
|
||||||
WireLength: int(frame.Header().Length),
|
|
||||||
Header: s.header.Copy(),
|
|
||||||
Compression: s.recvCompress,
|
|
||||||
}
|
|
||||||
t.statsHandler.HandleRPC(s.ctx, inHeader)
|
|
||||||
} else {
|
|
||||||
inTrailer := &stats.InTrailer{
|
|
||||||
Client: true,
|
|
||||||
WireLength: int(frame.Header().Length),
|
|
||||||
Trailer: s.trailer.Copy(),
|
|
||||||
}
|
|
||||||
t.statsHandler.HandleRPC(s.ctx, inTrailer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// If headerChan hasn't been closed yet
|
// If headerChan hasn't been closed yet
|
||||||
if atomic.CompareAndSwapUint32(&s.headerChanClosed, 0, 1) {
|
if atomic.CompareAndSwapUint32(&s.headerChanClosed, 0, 1) {
|
||||||
@ -1444,6 +1432,25 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
|
|||||||
close(s.headerChan)
|
close(s.headerChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.statsHandler != nil {
|
||||||
|
if isHeader {
|
||||||
|
inHeader := &stats.InHeader{
|
||||||
|
Client: true,
|
||||||
|
WireLength: int(frame.Header().Length),
|
||||||
|
Header: metadata.MD(mdata).Copy(),
|
||||||
|
Compression: s.recvCompress,
|
||||||
|
}
|
||||||
|
t.statsHandler.HandleRPC(s.ctx, inHeader)
|
||||||
|
} else {
|
||||||
|
inTrailer := &stats.InTrailer{
|
||||||
|
Client: true,
|
||||||
|
WireLength: int(frame.Header().Length),
|
||||||
|
Trailer: metadata.MD(mdata).Copy(),
|
||||||
|
}
|
||||||
|
t.statsHandler.HandleRPC(s.ctx, inTrailer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !endStream {
|
if !endStream {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
51
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
51
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
@ -129,7 +129,7 @@ type http2Server struct {
|
|||||||
// options from config.
|
// options from config.
|
||||||
//
|
//
|
||||||
// It returns a non-nil transport and a nil error on success. On failure, it
|
// It returns a non-nil transport and a nil error on success. On failure, it
|
||||||
// returns a non-nil transport and a nil-error. For a special case where the
|
// returns a nil transport and a non-nil error. For a special case where the
|
||||||
// underlying conn gets closed before the client preface could be read, it
|
// underlying conn gets closed before the client preface could be read, it
|
||||||
// returns a nil transport and a nil error.
|
// returns a nil transport and a nil error.
|
||||||
func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport, err error) {
|
func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport, err error) {
|
||||||
@ -290,10 +290,11 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
|
|||||||
if _, err := io.ReadFull(t.conn, preface); err != nil {
|
if _, err := io.ReadFull(t.conn, preface); err != nil {
|
||||||
// In deployments where a gRPC server runs behind a cloud load balancer
|
// In deployments where a gRPC server runs behind a cloud load balancer
|
||||||
// which performs regular TCP level health checks, the connection is
|
// which performs regular TCP level health checks, the connection is
|
||||||
// closed immediately by the latter. Skipping the error here will help
|
// closed immediately by the latter. Returning io.EOF here allows the
|
||||||
// reduce log clutter.
|
// grpc server implementation to recognize this scenario and suppress
|
||||||
|
// logging to reduce spam.
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
return nil, nil
|
return nil, io.EOF
|
||||||
}
|
}
|
||||||
return nil, connectionErrorf(false, err, "transport: http2Server.HandleStreams failed to receive the preface from client: %v", err)
|
return nil, connectionErrorf(false, err, "transport: http2Server.HandleStreams failed to receive the preface from client: %v", err)
|
||||||
}
|
}
|
||||||
@ -390,6 +391,13 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
|
|||||||
if timeout, err = decodeTimeout(hf.Value); err != nil {
|
if timeout, err = decodeTimeout(hf.Value); err != nil {
|
||||||
headerError = true
|
headerError = true
|
||||||
}
|
}
|
||||||
|
// "Transports must consider requests containing the Connection header
|
||||||
|
// as malformed." - A41
|
||||||
|
case "connection":
|
||||||
|
if logger.V(logLevel) {
|
||||||
|
logger.Errorf("transport: http2Server.operateHeaders parsed a :connection header which makes a request malformed as per the HTTP/2 spec")
|
||||||
|
}
|
||||||
|
headerError = true
|
||||||
default:
|
default:
|
||||||
if isReservedHeader(hf.Name) && !isWhitelistedHeader(hf.Name) {
|
if isReservedHeader(hf.Name) && !isWhitelistedHeader(hf.Name) {
|
||||||
break
|
break
|
||||||
@ -404,6 +412,25 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "If multiple Host headers or multiple :authority headers are present, the
|
||||||
|
// request must be rejected with an HTTP status code 400 as required by Host
|
||||||
|
// validation in RFC 7230 §5.4, gRPC status code INTERNAL, or RST_STREAM
|
||||||
|
// with HTTP/2 error code PROTOCOL_ERROR." - A41. Since this is a HTTP/2
|
||||||
|
// error, this takes precedence over a client not speaking gRPC.
|
||||||
|
if len(mdata[":authority"]) > 1 || len(mdata["host"]) > 1 {
|
||||||
|
errMsg := fmt.Sprintf("num values of :authority: %v, num values of host: %v, both must only have 1 value as per HTTP/2 spec", len(mdata[":authority"]), len(mdata["host"]))
|
||||||
|
if logger.V(logLevel) {
|
||||||
|
logger.Errorf("transport: %v", errMsg)
|
||||||
|
}
|
||||||
|
t.controlBuf.put(&earlyAbortStream{
|
||||||
|
httpStatus: 400,
|
||||||
|
streamID: streamID,
|
||||||
|
contentSubtype: s.contentSubtype,
|
||||||
|
status: status.New(codes.Internal, errMsg),
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if !isGRPC || headerError {
|
if !isGRPC || headerError {
|
||||||
t.controlBuf.put(&cleanupStream{
|
t.controlBuf.put(&cleanupStream{
|
||||||
streamID: streamID,
|
streamID: streamID,
|
||||||
@ -414,6 +441,19 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "If :authority is missing, Host must be renamed to :authority." - A41
|
||||||
|
if len(mdata[":authority"]) == 0 {
|
||||||
|
// No-op if host isn't present, no eventual :authority header is a valid
|
||||||
|
// RPC.
|
||||||
|
if host, ok := mdata["host"]; ok {
|
||||||
|
mdata[":authority"] = host
|
||||||
|
delete(mdata, "host")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// "If :authority is present, Host must be discarded" - A41
|
||||||
|
delete(mdata, "host")
|
||||||
|
}
|
||||||
|
|
||||||
if frame.StreamEnded() {
|
if frame.StreamEnded() {
|
||||||
// s is just created by the caller. No lock needed.
|
// s is just created by the caller. No lock needed.
|
||||||
s.state = streamReadDone
|
s.state = streamReadDone
|
||||||
@ -494,6 +534,7 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
|
|||||||
stat = status.New(codes.PermissionDenied, err.Error())
|
stat = status.New(codes.PermissionDenied, err.Error())
|
||||||
}
|
}
|
||||||
t.controlBuf.put(&earlyAbortStream{
|
t.controlBuf.put(&earlyAbortStream{
|
||||||
|
httpStatus: 200,
|
||||||
streamID: s.id,
|
streamID: s.id,
|
||||||
contentSubtype: s.contentSubtype,
|
contentSubtype: s.contentSubtype,
|
||||||
status: stat,
|
status: stat,
|
||||||
@ -734,7 +775,7 @@ func (t *http2Server) handleData(f *http2.DataFrame) {
|
|||||||
s.write(recvMsg{buffer: buffer})
|
s.write(recvMsg{buffer: buffer})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if f.Header().Flags.Has(http2.FlagDataEndStream) {
|
if f.StreamEnded() {
|
||||||
// Received the end of stream from the client.
|
// Received the end of stream from the client.
|
||||||
s.compareAndSwapState(streamActive, streamReadDone)
|
s.compareAndSwapState(streamActive, streamReadDone)
|
||||||
s.write(recvMsg{err: io.EOF})
|
s.write(recvMsg{err: io.EOF})
|
||||||
|
2
vendor/google.golang.org/grpc/internal/transport/networktype/networktype.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/transport/networktype/networktype.go
generated
vendored
@ -31,7 +31,7 @@ const key = keyType("grpc.internal.transport.networktype")
|
|||||||
|
|
||||||
// Set returns a copy of the provided address with attributes containing networkType.
|
// Set returns a copy of the provided address with attributes containing networkType.
|
||||||
func Set(address resolver.Address, networkType string) resolver.Address {
|
func Set(address resolver.Address, networkType string) resolver.Address {
|
||||||
address.Attributes = address.Attributes.WithValues(key, networkType)
|
address.Attributes = address.Attributes.WithValue(key, networkType)
|
||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
vendor/google.golang.org/grpc/internal/xds/env/env.go
generated
vendored
8
vendor/google.golang.org/grpc/internal/xds/env/env.go
generated
vendored
@ -43,7 +43,7 @@ const (
|
|||||||
clientSideSecuritySupportEnv = "GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT"
|
clientSideSecuritySupportEnv = "GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT"
|
||||||
aggregateAndDNSSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER"
|
aggregateAndDNSSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER"
|
||||||
retrySupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"
|
retrySupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"
|
||||||
rbacSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RBAC"
|
rbacSupportEnv = "GRPC_XDS_EXPERIMENTAL_RBAC"
|
||||||
|
|
||||||
c2pResolverSupportEnv = "GRPC_EXPERIMENTAL_GOOGLE_C2P_RESOLVER"
|
c2pResolverSupportEnv = "GRPC_EXPERIMENTAL_GOOGLE_C2P_RESOLVER"
|
||||||
c2pResolverTestOnlyTrafficDirectorURIEnv = "GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI"
|
c2pResolverTestOnlyTrafficDirectorURIEnv = "GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI"
|
||||||
@ -83,8 +83,10 @@ var (
|
|||||||
// RetrySupport indicates whether xDS retry is enabled.
|
// RetrySupport indicates whether xDS retry is enabled.
|
||||||
RetrySupport = !strings.EqualFold(os.Getenv(retrySupportEnv), "false")
|
RetrySupport = !strings.EqualFold(os.Getenv(retrySupportEnv), "false")
|
||||||
|
|
||||||
// RBACSupport indicates whether xDS configured RBAC HTTP Filter is enabled.
|
// RBACSupport indicates whether xDS configured RBAC HTTP Filter is enabled,
|
||||||
RBACSupport = strings.EqualFold(os.Getenv(rbacSupportEnv), "true")
|
// which can be disabled by setting the environment variable
|
||||||
|
// "GRPC_XDS_EXPERIMENTAL_RBAC" to "false".
|
||||||
|
RBACSupport = !strings.EqualFold(os.Getenv(rbacSupportEnv), "false")
|
||||||
|
|
||||||
// C2PResolverSupport indicates whether support for C2P resolver is enabled.
|
// C2PResolverSupport indicates whether support for C2P resolver is enabled.
|
||||||
// This can be enabled by setting the environment variable
|
// This can be enabled by setting the environment variable
|
||||||
|
2
vendor/google.golang.org/grpc/internal/xds_handshake_cluster.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/xds_handshake_cluster.go
generated
vendored
@ -28,7 +28,7 @@ type handshakeClusterNameKey struct{}
|
|||||||
// SetXDSHandshakeClusterName returns a copy of addr in which the Attributes field
|
// SetXDSHandshakeClusterName returns a copy of addr in which the Attributes field
|
||||||
// is updated with the cluster name.
|
// is updated with the cluster name.
|
||||||
func SetXDSHandshakeClusterName(addr resolver.Address, clusterName string) resolver.Address {
|
func SetXDSHandshakeClusterName(addr resolver.Address, clusterName string) resolver.Address {
|
||||||
addr.Attributes = addr.Attributes.WithValues(handshakeClusterNameKey{}, clusterName)
|
addr.Attributes = addr.Attributes.WithValue(handshakeClusterNameKey{}, clusterName)
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vendor/google.golang.org/grpc/picker_wrapper.go
generated
vendored
2
vendor/google.golang.org/grpc/picker_wrapper.go
generated
vendored
@ -144,7 +144,7 @@ func (pw *pickerWrapper) pick(ctx context.Context, failfast bool, info balancer.
|
|||||||
|
|
||||||
acw, ok := pickResult.SubConn.(*acBalancerWrapper)
|
acw, ok := pickResult.SubConn.(*acBalancerWrapper)
|
||||||
if !ok {
|
if !ok {
|
||||||
logger.Error("subconn returned from pick is not *acBalancerWrapper")
|
logger.Errorf("subconn returned from pick is type %T, not *acBalancerWrapper", pickResult.SubConn)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if t := acw.getAddrConn().getReadyTransport(); t != nil {
|
if t := acw.getAddrConn().getReadyTransport(); t != nil {
|
||||||
|
109
vendor/google.golang.org/grpc/resolver/map.go
generated
vendored
Normal file
109
vendor/google.golang.org/grpc/resolver/map.go
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2021 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 resolver
|
||||||
|
|
||||||
|
type addressMapEntry struct {
|
||||||
|
addr Address
|
||||||
|
value interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddressMap is a map of addresses to arbitrary values taking into account
|
||||||
|
// Attributes. BalancerAttributes are ignored, as are Metadata and Type.
|
||||||
|
// Multiple accesses may not be performed concurrently. Must be created via
|
||||||
|
// NewAddressMap; do not construct directly.
|
||||||
|
type AddressMap struct {
|
||||||
|
m map[string]addressMapEntryList
|
||||||
|
}
|
||||||
|
|
||||||
|
type addressMapEntryList []*addressMapEntry
|
||||||
|
|
||||||
|
// NewAddressMap creates a new AddressMap.
|
||||||
|
func NewAddressMap() *AddressMap {
|
||||||
|
return &AddressMap{m: make(map[string]addressMapEntryList)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find returns the index of addr in the addressMapEntry slice, or -1 if not
|
||||||
|
// present.
|
||||||
|
func (l addressMapEntryList) find(addr Address) int {
|
||||||
|
if len(l) == 0 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
for i, entry := range l {
|
||||||
|
if entry.addr.ServerName == addr.ServerName &&
|
||||||
|
entry.addr.Attributes.Equal(addr.Attributes) {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns the value for the address in the map, if present.
|
||||||
|
func (a *AddressMap) Get(addr Address) (value interface{}, ok bool) {
|
||||||
|
entryList := a.m[addr.Addr]
|
||||||
|
if entry := entryList.find(addr); entry != -1 {
|
||||||
|
return entryList[entry].value, true
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set updates or adds the value to the address in the map.
|
||||||
|
func (a *AddressMap) Set(addr Address, value interface{}) {
|
||||||
|
entryList := a.m[addr.Addr]
|
||||||
|
if entry := entryList.find(addr); entry != -1 {
|
||||||
|
a.m[addr.Addr][entry].value = value
|
||||||
|
return
|
||||||
|
}
|
||||||
|
a.m[addr.Addr] = append(a.m[addr.Addr], &addressMapEntry{addr: addr, value: value})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete removes addr from the map.
|
||||||
|
func (a *AddressMap) Delete(addr Address) {
|
||||||
|
entryList := a.m[addr.Addr]
|
||||||
|
entry := entryList.find(addr)
|
||||||
|
if entry == -1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(entryList) == 1 {
|
||||||
|
entryList = nil
|
||||||
|
} else {
|
||||||
|
copy(entryList[entry:], entryList[entry+1:])
|
||||||
|
entryList = entryList[:len(entryList)-1]
|
||||||
|
}
|
||||||
|
a.m[addr.Addr] = entryList
|
||||||
|
}
|
||||||
|
|
||||||
|
// Len returns the number of entries in the map.
|
||||||
|
func (a *AddressMap) Len() int {
|
||||||
|
ret := 0
|
||||||
|
for _, entryList := range a.m {
|
||||||
|
ret += len(entryList)
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keys returns a slice of all current map keys.
|
||||||
|
func (a *AddressMap) Keys() []Address {
|
||||||
|
ret := make([]Address, 0, a.Len())
|
||||||
|
for _, entryList := range a.m {
|
||||||
|
for _, entry := range entryList {
|
||||||
|
ret = append(ret, entry.addr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
56
vendor/google.golang.org/grpc/resolver/resolver.go
generated
vendored
56
vendor/google.golang.org/grpc/resolver/resolver.go
generated
vendored
@ -23,6 +23,7 @@ package resolver
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"google.golang.org/grpc/attributes"
|
"google.golang.org/grpc/attributes"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
@ -116,9 +117,14 @@ type Address struct {
|
|||||||
ServerName string
|
ServerName string
|
||||||
|
|
||||||
// Attributes contains arbitrary data about this address intended for
|
// Attributes contains arbitrary data about this address intended for
|
||||||
// consumption by the load balancing policy.
|
// consumption by the SubConn.
|
||||||
Attributes *attributes.Attributes
|
Attributes *attributes.Attributes
|
||||||
|
|
||||||
|
// BalancerAttributes contains arbitrary data about this address intended
|
||||||
|
// for consumption by the LB policy. These attribes do not affect SubConn
|
||||||
|
// creation, connection establishment, handshaking, etc.
|
||||||
|
BalancerAttributes *attributes.Attributes
|
||||||
|
|
||||||
// Type is the type of this address.
|
// Type is the type of this address.
|
||||||
//
|
//
|
||||||
// Deprecated: use Attributes instead.
|
// Deprecated: use Attributes instead.
|
||||||
@ -131,6 +137,15 @@ type Address struct {
|
|||||||
Metadata interface{}
|
Metadata interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Equal returns whether a and o are identical. Metadata is compared directly,
|
||||||
|
// not with any recursive introspection.
|
||||||
|
func (a *Address) Equal(o Address) bool {
|
||||||
|
return a.Addr == o.Addr && a.ServerName == o.ServerName &&
|
||||||
|
a.Attributes.Equal(o.Attributes) &&
|
||||||
|
a.BalancerAttributes.Equal(o.BalancerAttributes) &&
|
||||||
|
a.Type == o.Type && a.Metadata == o.Metadata
|
||||||
|
}
|
||||||
|
|
||||||
// BuildOptions includes additional information for the builder to create
|
// BuildOptions includes additional information for the builder to create
|
||||||
// the resolver.
|
// the resolver.
|
||||||
type BuildOptions struct {
|
type BuildOptions struct {
|
||||||
@ -204,25 +219,36 @@ type ClientConn interface {
|
|||||||
|
|
||||||
// Target represents a target for gRPC, as specified in:
|
// Target represents a target for gRPC, as specified in:
|
||||||
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
|
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
|
||||||
// It is parsed from the target string that gets passed into Dial or DialContext by the user. And
|
// It is parsed from the target string that gets passed into Dial or DialContext
|
||||||
// grpc passes it to the resolver and the balancer.
|
// by the user. And gRPC passes it to the resolver and the balancer.
|
||||||
//
|
//
|
||||||
// If the target follows the naming spec, and the parsed scheme is registered with grpc, we will
|
// If the target follows the naming spec, and the parsed scheme is registered
|
||||||
// parse the target string according to the spec. e.g. "dns://some_authority/foo.bar" will be parsed
|
// with gRPC, we will parse the target string according to the spec. If the
|
||||||
// into &Target{Scheme: "dns", Authority: "some_authority", Endpoint: "foo.bar"}
|
// target does not contain a scheme or if the parsed scheme is not registered
|
||||||
|
// (i.e. no corresponding resolver available to resolve the endpoint), we will
|
||||||
|
// apply the default scheme, and will attempt to reparse it.
|
||||||
//
|
//
|
||||||
// If the target does not contain a scheme, we will apply the default scheme, and set the Target to
|
// Examples:
|
||||||
// be the full target string. e.g. "foo.bar" will be parsed into
|
|
||||||
// &Target{Scheme: resolver.GetDefaultScheme(), Endpoint: "foo.bar"}.
|
|
||||||
//
|
//
|
||||||
// If the parsed scheme is not registered (i.e. no corresponding resolver available to resolve the
|
// - "dns://some_authority/foo.bar"
|
||||||
// endpoint), we set the Scheme to be the default scheme, and set the Endpoint to be the full target
|
// Target{Scheme: "dns", Authority: "some_authority", Endpoint: "foo.bar"}
|
||||||
// string. e.g. target string "unknown_scheme://authority/endpoint" will be parsed into
|
// - "foo.bar"
|
||||||
// &Target{Scheme: resolver.GetDefaultScheme(), Endpoint: "unknown_scheme://authority/endpoint"}.
|
// Target{Scheme: resolver.GetDefaultScheme(), Endpoint: "foo.bar"}
|
||||||
|
// - "unknown_scheme://authority/endpoint"
|
||||||
|
// Target{Scheme: resolver.GetDefaultScheme(), Endpoint: "unknown_scheme://authority/endpoint"}
|
||||||
type Target struct {
|
type Target struct {
|
||||||
Scheme string
|
// Deprecated: use URL.Scheme instead.
|
||||||
|
Scheme string
|
||||||
|
// Deprecated: use URL.Host instead.
|
||||||
Authority string
|
Authority string
|
||||||
Endpoint string
|
// Deprecated: use URL.Path or URL.Opaque instead. The latter is set when
|
||||||
|
// the former is empty.
|
||||||
|
Endpoint string
|
||||||
|
// URL contains the parsed dial target with an optional default scheme added
|
||||||
|
// to it if the original dial target contained no scheme or contained an
|
||||||
|
// unregistered scheme. Any query params specified in the original dial
|
||||||
|
// target can be accessed from here.
|
||||||
|
URL url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Builder creates a resolver that will be used to watch name resolution updates.
|
// Builder creates a resolver that will be used to watch name resolution updates.
|
||||||
|
52
vendor/google.golang.org/grpc/server.go
generated
vendored
52
vendor/google.golang.org/grpc/server.go
generated
vendored
@ -885,13 +885,11 @@ func (s *Server) newHTTP2Transport(c net.Conn) transport.ServerTransport {
|
|||||||
// ErrConnDispatched means that the connection was dispatched away from
|
// ErrConnDispatched means that the connection was dispatched away from
|
||||||
// gRPC; those connections should be left open.
|
// gRPC; those connections should be left open.
|
||||||
if err != credentials.ErrConnDispatched {
|
if err != credentials.ErrConnDispatched {
|
||||||
c.Close()
|
// Don't log on ErrConnDispatched and io.EOF to prevent log spam.
|
||||||
}
|
|
||||||
// Don't log on ErrConnDispatched and io.EOF to prevent log spam.
|
|
||||||
if err != credentials.ErrConnDispatched {
|
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
channelz.Warning(logger, s.channelzID, "grpc: Server.Serve failed to create ServerTransport: ", err)
|
channelz.Warning(logger, s.channelzID, "grpc: Server.Serve failed to create ServerTransport: ", err)
|
||||||
}
|
}
|
||||||
|
c.Close()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1106,16 +1104,21 @@ func chainUnaryServerInterceptors(s *Server) {
|
|||||||
|
|
||||||
func chainUnaryInterceptors(interceptors []UnaryServerInterceptor) UnaryServerInterceptor {
|
func chainUnaryInterceptors(interceptors []UnaryServerInterceptor) UnaryServerInterceptor {
|
||||||
return func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (interface{}, error) {
|
return func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (interface{}, error) {
|
||||||
var i int
|
// the struct ensures the variables are allocated together, rather than separately, since we
|
||||||
var next UnaryHandler
|
// know they should be garbage collected together. This saves 1 allocation and decreases
|
||||||
next = func(ctx context.Context, req interface{}) (interface{}, error) {
|
// time/call by about 10% on the microbenchmark.
|
||||||
if i == len(interceptors)-1 {
|
var state struct {
|
||||||
return interceptors[i](ctx, req, info, handler)
|
i int
|
||||||
}
|
next UnaryHandler
|
||||||
i++
|
|
||||||
return interceptors[i-1](ctx, req, info, next)
|
|
||||||
}
|
}
|
||||||
return next(ctx, req)
|
state.next = func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
if state.i == len(interceptors)-1 {
|
||||||
|
return interceptors[state.i](ctx, req, info, handler)
|
||||||
|
}
|
||||||
|
state.i++
|
||||||
|
return interceptors[state.i-1](ctx, req, info, state.next)
|
||||||
|
}
|
||||||
|
return state.next(ctx, req)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1391,16 +1394,21 @@ func chainStreamServerInterceptors(s *Server) {
|
|||||||
|
|
||||||
func chainStreamInterceptors(interceptors []StreamServerInterceptor) StreamServerInterceptor {
|
func chainStreamInterceptors(interceptors []StreamServerInterceptor) StreamServerInterceptor {
|
||||||
return func(srv interface{}, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error {
|
return func(srv interface{}, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error {
|
||||||
var i int
|
// the struct ensures the variables are allocated together, rather than separately, since we
|
||||||
var next StreamHandler
|
// know they should be garbage collected together. This saves 1 allocation and decreases
|
||||||
next = func(srv interface{}, ss ServerStream) error {
|
// time/call by about 10% on the microbenchmark.
|
||||||
if i == len(interceptors)-1 {
|
var state struct {
|
||||||
return interceptors[i](srv, ss, info, handler)
|
i int
|
||||||
}
|
next StreamHandler
|
||||||
i++
|
|
||||||
return interceptors[i-1](srv, ss, info, next)
|
|
||||||
}
|
}
|
||||||
return next(srv, ss)
|
state.next = func(srv interface{}, ss ServerStream) error {
|
||||||
|
if state.i == len(interceptors)-1 {
|
||||||
|
return interceptors[state.i](srv, ss, info, handler)
|
||||||
|
}
|
||||||
|
state.i++
|
||||||
|
return interceptors[state.i-1](srv, ss, info, state.next)
|
||||||
|
}
|
||||||
|
return state.next(srv, ss)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
vendor/google.golang.org/grpc/status/status.go
generated
vendored
15
vendor/google.golang.org/grpc/status/status.go
generated
vendored
@ -73,11 +73,16 @@ func FromProto(s *spb.Status) *Status {
|
|||||||
return status.FromProto(s)
|
return status.FromProto(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromError returns a Status representing err if it was produced by this
|
// FromError returns a Status representation of err.
|
||||||
// package or has a method `GRPCStatus() *Status`.
|
//
|
||||||
// If err is nil, a Status is returned with codes.OK and no message.
|
// - If err was produced by this package or implements the method `GRPCStatus()
|
||||||
// Otherwise, ok is false and a Status is returned with codes.Unknown and
|
// *Status`, the appropriate Status is returned.
|
||||||
// the original error message.
|
//
|
||||||
|
// - If err is nil, a Status is returned with codes.OK and no message.
|
||||||
|
//
|
||||||
|
// - Otherwise, err is an error not compatible with this package. In this
|
||||||
|
// case, a Status is returned with codes.Unknown and err's Error() message,
|
||||||
|
// and ok is false.
|
||||||
func FromError(err error) (s *Status, ok bool) {
|
func FromError(err error) (s *Status, ok bool) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil, true
|
return nil, true
|
||||||
|
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
|
package grpc
|
||||||
|
|
||||||
// Version is the current grpc version.
|
// Version is the current grpc version.
|
||||||
const Version = "1.41.0"
|
const Version = "1.42.0"
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -484,7 +484,7 @@ google.golang.org/appengine/urlfetch
|
|||||||
google.golang.org/genproto/googleapis/api/httpbody
|
google.golang.org/genproto/googleapis/api/httpbody
|
||||||
google.golang.org/genproto/googleapis/rpc/status
|
google.golang.org/genproto/googleapis/rpc/status
|
||||||
google.golang.org/genproto/protobuf/field_mask
|
google.golang.org/genproto/protobuf/field_mask
|
||||||
# google.golang.org/grpc v1.41.0
|
# google.golang.org/grpc v1.42.0
|
||||||
## explicit
|
## explicit
|
||||||
google.golang.org/grpc
|
google.golang.org/grpc
|
||||||
google.golang.org/grpc/attributes
|
google.golang.org/grpc/attributes
|
||||||
|
Loading…
Reference in New Issue
Block a user