summaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/grpc/balancer
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/grpc/balancer')
-rw-r--r--vendor/google.golang.org/grpc/balancer/balancer.go14
-rw-r--r--vendor/google.golang.org/grpc/balancer/base/balancer.go53
2 files changed, 10 insertions, 57 deletions
diff --git a/vendor/google.golang.org/grpc/balancer/balancer.go b/vendor/google.golang.org/grpc/balancer/balancer.go
index ab531f4c0..8bf359dbf 100644
--- a/vendor/google.golang.org/grpc/balancer/balancer.go
+++ b/vendor/google.golang.org/grpc/balancer/balancer.go
@@ -101,9 +101,6 @@ type SubConn interface {
// a new connection will be created.
//
// This will trigger a state transition for the SubConn.
- //
- // Deprecated: This method is now part of the ClientConn interface and will
- // eventually be removed from here.
UpdateAddresses([]resolver.Address)
// Connect starts the connecting for this SubConn.
Connect()
@@ -146,13 +143,6 @@ type ClientConn interface {
// RemoveSubConn removes the SubConn from ClientConn.
// The SubConn will be shutdown.
RemoveSubConn(SubConn)
- // UpdateAddresses updates the addresses used in the passed in SubConn.
- // gRPC checks if the currently connected address is still in the new list.
- // If so, the connection will be kept. Else, the connection will be
- // gracefully closed, and a new connection will be created.
- //
- // This will trigger a state transition for the SubConn.
- UpdateAddresses(SubConn, []resolver.Address)
// UpdateState notifies gRPC that the balancer's internal state has
// changed.
@@ -184,10 +174,6 @@ type BuildOptions struct {
Dialer func(context.Context, string) (net.Conn, error)
// ChannelzParentID is the entity parent's channelz unique identification number.
ChannelzParentID int64
- // CustomUserAgent is the custom user agent set on the parent ClientConn.
- // The balancer should set the same custom user agent if it creates a
- // ClientConn.
- CustomUserAgent string
// Target contains the parsed address info of the dial target. It is the same resolver.Target as
// passed to the resolver.
// See the documentation for the resolver.Target type for details about what it contains.
diff --git a/vendor/google.golang.org/grpc/balancer/base/balancer.go b/vendor/google.golang.org/grpc/balancer/base/balancer.go
index c883efa0b..32d782f1c 100644
--- a/vendor/google.golang.org/grpc/balancer/base/balancer.go
+++ b/vendor/google.golang.org/grpc/balancer/base/balancer.go
@@ -22,7 +22,6 @@ import (
"errors"
"fmt"
- "google.golang.org/grpc/attributes"
"google.golang.org/grpc/balancer"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/grpclog"
@@ -42,7 +41,7 @@ func (bb *baseBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions)
cc: cc,
pickerBuilder: bb.pickerBuilder,
- subConns: make(map[resolver.Address]subConnInfo),
+ subConns: make(map[resolver.Address]balancer.SubConn),
scStates: make(map[balancer.SubConn]connectivity.State),
csEvltr: &balancer.ConnectivityStateEvaluator{},
config: bb.config,
@@ -58,11 +57,6 @@ func (bb *baseBuilder) Name() string {
return bb.name
}
-type subConnInfo struct {
- subConn balancer.SubConn
- attrs *attributes.Attributes
-}
-
type baseBalancer struct {
cc balancer.ClientConn
pickerBuilder PickerBuilder
@@ -70,7 +64,7 @@ type baseBalancer struct {
csEvltr *balancer.ConnectivityStateEvaluator
state connectivity.State
- subConns map[resolver.Address]subConnInfo // `attributes` is stripped from the keys of this map (the addresses)
+ subConns map[resolver.Address]balancer.SubConn
scStates map[balancer.SubConn]connectivity.State
picker balancer.Picker
config Config
@@ -107,49 +101,23 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
// addrsSet is the set converted from addrs, it's used for quick lookup of an address.
addrsSet := make(map[resolver.Address]struct{})
for _, a := range s.ResolverState.Addresses {
- // Strip attributes from addresses before using them as map keys. So
- // that when two addresses only differ in attributes pointers (but with
- // 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 {
+ addrsSet[a] = struct{}{}
+ if _, ok := b.subConns[a]; !ok {
// 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})
if err != nil {
logger.Warningf("base.baseBalancer: failed to create new SubConn: %v", err)
continue
}
- b.subConns[aNoAttrs] = subConnInfo{subConn: sc, attrs: a.Attributes}
+ b.subConns[a] = sc
b.scStates[sc] = connectivity.Idle
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, sc := range b.subConns {
// a was removed by resolver.
if _, ok := addrsSet[a]; !ok {
- b.cc.RemoveSubConn(scInfo.subConn)
+ b.cc.RemoveSubConn(sc)
delete(b.subConns, a)
// Keep the state of this sc in b.scStates until sc's state becomes Shutdown.
// The entry will be deleted in UpdateSubConnState.
@@ -192,10 +160,9 @@ func (b *baseBalancer) regeneratePicker() {
readySCs := make(map[balancer.SubConn]SubConnInfo)
// Filter out all ready SCs from full subConn map.
- for addr, scInfo := range b.subConns {
- if st, ok := b.scStates[scInfo.subConn]; ok && st == connectivity.Ready {
- addr.Attributes = scInfo.attrs
- readySCs[scInfo.subConn] = SubConnInfo{Address: addr}
+ for addr, sc := range b.subConns {
+ if st, ok := b.scStates[sc]; ok && st == connectivity.Ready {
+ readySCs[sc] = SubConnInfo{Address: addr}
}
}
b.picker = b.pickerBuilder.Build(PickerBuildInfo{ReadySCs: readySCs})