channelz: unexport unnecessary API on grpc entities (#2257)
This commit is contained in:
@ -146,9 +146,9 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
|||||||
|
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
if cc.dopts.channelzParentID != 0 {
|
if cc.dopts.channelzParentID != 0 {
|
||||||
cc.channelzID = channelz.RegisterChannel(cc, cc.dopts.channelzParentID, target)
|
cc.channelzID = channelz.RegisterChannel(&channelzChannel{cc}, cc.dopts.channelzParentID, target)
|
||||||
} else {
|
} else {
|
||||||
cc.channelzID = channelz.RegisterChannel(cc, 0, target)
|
cc.channelzID = channelz.RegisterChannel(&channelzChannel{cc}, 0, target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,9 +562,7 @@ func (cc *ClientConn) removeAddrConn(ac *addrConn, err error) {
|
|||||||
ac.tearDown(err)
|
ac.tearDown(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelzMetric returns ChannelInternalMetric of current ClientConn.
|
func (cc *ClientConn) channelzMetric() *channelz.ChannelInternalMetric {
|
||||||
// This is an EXPERIMENTAL API.
|
|
||||||
func (cc *ClientConn) ChannelzMetric() *channelz.ChannelInternalMetric {
|
|
||||||
return &channelz.ChannelInternalMetric{
|
return &channelz.ChannelInternalMetric{
|
||||||
State: cc.GetState(),
|
State: cc.GetState(),
|
||||||
Target: cc.target,
|
Target: cc.target,
|
||||||
@ -1241,6 +1239,14 @@ func (rt *retryThrottler) successfulRPC() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type channelzChannel struct {
|
||||||
|
cc *ClientConn
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelzChannel) ChannelzMetric() *channelz.ChannelInternalMetric {
|
||||||
|
return c.cc.channelzMetric()
|
||||||
|
}
|
||||||
|
|
||||||
// ErrClientConnTimeout indicates that the ClientConn cannot establish the
|
// ErrClientConnTimeout indicates that the ClientConn cannot establish the
|
||||||
// underlying connections within the specified timeout.
|
// underlying connections within the specified timeout.
|
||||||
//
|
//
|
||||||
|
14
server.go
14
server.go
@ -369,7 +369,7 @@ func NewServer(opt ...ServerOption) *Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
s.channelzID = channelz.RegisterServer(s, "")
|
s.channelzID = channelz.RegisterServer(&channelzServer{s}, "")
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@ -779,9 +779,7 @@ func (s *Server) removeConn(c io.Closer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelzMetric returns ServerInternalMetric of current server.
|
func (s *Server) channelzMetric() *channelz.ServerInternalMetric {
|
||||||
// This is an EXPERIMENTAL API.
|
|
||||||
func (s *Server) ChannelzMetric() *channelz.ServerInternalMetric {
|
|
||||||
return &channelz.ServerInternalMetric{
|
return &channelz.ServerInternalMetric{
|
||||||
CallsStarted: atomic.LoadInt64(&s.czData.callsStarted),
|
CallsStarted: atomic.LoadInt64(&s.czData.callsStarted),
|
||||||
CallsSucceeded: atomic.LoadInt64(&s.czData.callsSucceeded),
|
CallsSucceeded: atomic.LoadInt64(&s.czData.callsSucceeded),
|
||||||
@ -1439,3 +1437,11 @@ func Method(ctx context.Context) (string, bool) {
|
|||||||
}
|
}
|
||||||
return s.Method(), true
|
return s.Method(), true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type channelzServer struct {
|
||||||
|
s *Server
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelzServer) ChannelzMetric() *channelz.ServerInternalMetric {
|
||||||
|
return c.s.channelzMetric()
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user