ClientConn: add Target() returning target string (#2233)
This commit is contained in:
@ -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() {
|
func (cc *ClientConn) incrCallsStarted() {
|
||||||
cc.czmu.Lock()
|
cc.czmu.Lock()
|
||||||
cc.callsStarted++
|
cc.callsStarted++
|
||||||
|
@ -689,3 +689,15 @@ func TestDisableServiceConfigOption(t *testing.T) {
|
|||||||
t.Fatalf("want: method (\"/foo/bar/\") config to be empty, got: %v", m)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user