mirror of https://github.com/grpc/grpc-go.git
ClientConn: add Target() returning target string (#2233)
This commit is contained in:
parent
445634bdcc
commit
980d9e0348
|
@ -580,6 +580,12 @@ func (cc *ClientConn) ChannelzMetric() *channelz.ChannelInternalMetric {
|
|||
}
|
||||
}
|
||||
|
||||
// Target returns the target string of the ClientConn.
|
||||
// This is an EXPERIMENTAL API.
|
||||
func (cc *ClientConn) Target() string {
|
||||
return cc.target
|
||||
}
|
||||
|
||||
func (cc *ClientConn) incrCallsStarted() {
|
||||
cc.czmu.Lock()
|
||||
cc.callsStarted++
|
||||
|
|
|
@ -689,3 +689,15 @@ func TestDisableServiceConfigOption(t *testing.T) {
|
|||
t.Fatalf("want: method (\"/foo/bar/\") config to be empty, got: %v", m)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetClientConnTarget(t *testing.T) {
|
||||
addr := "nonexist:///non.existent"
|
||||
cc, err := Dial(addr, WithInsecure())
|
||||
if err != nil {
|
||||
t.Fatalf("Dial(%s, _) = _, %v, want _, <nil>", addr, err)
|
||||
}
|
||||
defer cc.Close()
|
||||
if cc.Target() != addr {
|
||||
t.Fatalf("Target() = %s, want %s", cc.Target(), addr)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue