Skip to content

Commit

Permalink
Review comments #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Apr 23, 2020
1 parent ddba927 commit 6943940
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 1 addition & 3 deletions balancer/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type NewSubConnOptions struct {
// CredsBundle is the credentials bundle that will be used in the created
// SubConn. If it's nil, the original creds from grpc DialOptions will be
// used.
//
// Deprecated: Use the Attributes field in resolver.Address to pass
// arbitrary data to the credential handshaker.
CredsBundle credentials.Bundle
Expand Down Expand Up @@ -138,9 +139,6 @@ type ClientConn interface {
// NewSubConn is called by balancer to create a new SubConn.
// It doesn't block and wait for the connections to be established.
// Behaviors of the SubConn can be controlled by options.
//
// Attributes field in resolver.Address can be used to pass arbitrary data
// to the credential handshaker.
NewSubConn([]resolver.Address, NewSubConnOptions) (SubConn, error)
// RemoveSubConn removes the SubConn from ClientConn.
// The SubConn will be shutdown.
Expand Down
10 changes: 5 additions & 5 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,11 @@ func (ac *addrConn) createTransport(addr resolver.Address, copts transport.Conne
copts.ChannelzParentID = ac.channelzID
}

// Balancer implementations can specify arbitrary data in the Attributes
// field of resolver.Address, which is shoved into connectCtx that is passed
// to the transport layer. The transport layer passes the same context to
// the credential handshaker. This makes is possible for address specific
// arbitrary data from balancers to reach the credential handshaker.
// gRPC, resolver, balancer etc. can specify arbitrary data in the
// Attributes field of resolver.Address, which is shoved into connectCtx
// that is passed to the transport layer. The transport layer passes the
// same context to the credential handshaker. This makes is possible for
// address specific arbitrary data to reach the credential handshaker.
connectCtx = credentials.WithAddressInfo(connectCtx, credentials.AddressInfo{Attr: addr.Attributes})
newTr, err := transport.NewClientTransport(connectCtx, ac.cc.ctx, addr, copts, onPrefaceReceipt, onGoAway, onClose)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ func RequestInfoFromContext(ctx context.Context) (ri RequestInfo, ok bool) {
}

// AddressInfo contains address related data attached to the context passed to
// ClientHandshake. This makes it possible for balancer implementations to pass
// arbitrary data to the handshaker. Individual credential implementations
// control the actual format of the data that they are willing to receive.
// ClientHandshake. This makes it possible to pass arbitrary data to the
// handshaker from gRPC, resolver, balancer etc. Individual credential
// implementations control the actual format of the data that they are willing
// to receive.
//
// This API is experimental.
type AddressInfo struct {
Expand Down

0 comments on commit 6943940

Please sign in to comment.