Skip to content

Commit 90985d4

Browse files
committed
review comments
1 parent 2217e0c commit 90985d4

File tree

3 files changed

+10
-48
lines changed

3 files changed

+10
-48
lines changed

balancer/grpclb/grpclb_remote_balancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (lb *lbBalancer) newRemoteBalancerCCWrapper() error {
246246
// Explicitly set pickfirst as the balancer.
247247
dopts = append(dopts, grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"pick_first"}`))
248248
dopts = append(dopts, grpc.WithResolvers(lb.manualResolver))
249-
dopts = append(dopts, grpc.WithChannelzParent(lb.opt.ChannelzParent))
249+
dopts = append(dopts, grpc.WithChannelzParentID(lb.opt.ChannelzParent))
250250

251251
// Enable Keepalive for grpclb client.
252252
dopts = append(dopts, grpc.WithKeepaliveParams(keepalive.ClientParameters{

clientconn.go

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,10 @@ func (cc *ClientConn) validateTransportCredentials() error {
417417
}
418418

419419
// channelzRegistration registers the newly created ClientConn with channelz and
420-
// stores the returned identifier in `cc.channelzID` and `cc.csMgr.channelzID`.
421-
// A channelz trace event is emitted for ClientConn creation. If the newly
422-
// created ClientConn is a nested one, i.e a valid parent ClientConn ID is
423-
// specified via a dial option, the trace event is also added to the parent.
420+
// stores the returned identifier in `cc.channelz`. A channelz trace event is
421+
// emitted for ClientConn creation. If the newly created ClientConn is a nested
422+
// one, i.e a valid parent ClientConn ID is specified via a dial option, the
423+
// trace event is also added to the parent.
424424
//
425425
// Doesn't grab cc.mu as this method is expected to be called only at Dial time.
426426
func (cc *ClientConn) channelzRegistration(target string) {
@@ -492,10 +492,10 @@ func getChainStreamer(interceptors []StreamClientInterceptor, curr int, finalStr
492492
}
493493

494494
// newConnectivityStateManager creates an connectivityStateManager with
495-
// the specified id.
496-
func newConnectivityStateManager(ctx context.Context, id *channelz.Channel) *connectivityStateManager {
495+
// the specified channel.
496+
func newConnectivityStateManager(ctx context.Context, channel *channelz.Channel) *connectivityStateManager {
497497
return &connectivityStateManager{
498-
channelz: id,
498+
channelz: channel,
499499
pubSub: grpcsync.NewPubSub(ctx),
500500
}
501501
}
@@ -1548,16 +1548,6 @@ func (ac *addrConn) tearDown(err error) {
15481548
ac.cancel()
15491549
ac.curAddr = resolver.Address{}
15501550

1551-
if err == errConnDrain && curTr != nil {
1552-
// GracefulClose(...) may be executed multiple times when
1553-
// i) receiving multiple GoAway frames from the server; or
1554-
// ii) there are concurrent name resolver/Balancer triggered
1555-
// address removal and GoAway.
1556-
// We have to unlock and re-lock here because GracefulClose => Close => onClose, which requires locking ac.mu.
1557-
ac.mu.Unlock()
1558-
curTr.GracefulClose()
1559-
ac.mu.Lock()
1560-
}
15611551
channelz.AddTraceEvent(logger, ac.channelz, 0, &channelz.TraceEvent{
15621552
Desc: "Subchannel deleted",
15631553
Severity: channelz.CtInfo,
@@ -1633,34 +1623,6 @@ func (rt *retryThrottler) successfulRPC() {
16331623
}
16341624
}
16351625

1636-
/*
1637-
func (c *channelzChannel) ChannelzMetric() *channelz.ChannelInternalMetric {
1638-
cc := c.cc
1639-
return &channelz.ChannelInternalMetric{
1640-
State: cc.GetState(),
1641-
Target: cc.target,
1642-
CallsStarted: atomic.LoadInt64(&cc.czData.callsStarted),
1643-
CallsSucceeded: atomic.LoadInt64(&cc.czData.callsSucceeded),
1644-
CallsFailed: atomic.LoadInt64(&cc.czData.callsFailed),
1645-
LastCallStartedTimestamp: time.Unix(0, atomic.LoadInt64(&cc.czData.lastCallStartedTime)),
1646-
}
1647-
}
1648-
1649-
func (ac *addrConn) ChannelzMetric() *channelz.ChannelInternalMetric {
1650-
ac.mu.Lock()
1651-
addr := ac.curAddr.Addr
1652-
ac.mu.Unlock()
1653-
return &channelz.ChannelInternalMetric{
1654-
State: ac.getState(),
1655-
Target: addr,
1656-
CallsStarted: atomic.LoadInt64(&ac.czData.callsStarted),
1657-
CallsSucceeded: atomic.LoadInt64(&ac.czData.callsSucceeded),
1658-
CallsFailed: atomic.LoadInt64(&ac.czData.callsFailed),
1659-
LastCallStartedTimestamp: time.Unix(0, atomic.LoadInt64(&ac.czData.lastCallStartedTime)),
1660-
}
1661-
}
1662-
*/
1663-
16641626
func (ac *addrConn) incrCallsStarted() {
16651627
ac.channelz.ChannelMetrics.CallsStarted.Add(1)
16661628
ac.channelz.ChannelMetrics.LastCallStartedTimestamp.Store(time.Now().UnixNano())

dialoptions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,15 @@ func WithAuthority(a string) DialOption {
547547
})
548548
}
549549

550-
// WithChannelzParent returns a DialOption that specifies the channelz ID of
550+
// WithChannelzParentID returns a DialOption that specifies the channelz ID of
551551
// current ClientConn's parent. This function is used in nested channel creation
552552
// (e.g. grpclb dial).
553553
//
554554
// # Experimental
555555
//
556556
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
557557
// later release.
558-
func WithChannelzParent(c channelz.Identifier) DialOption {
558+
func WithChannelzParentID(c channelz.Identifier) DialOption {
559559
return newFuncDialOption(func(o *dialOptions) {
560560
o.channelzParent = c
561561
})

0 commit comments

Comments
 (0)