Skip to content

Commit 3c89e45

Browse files
dfawleyjanardhankrishna-sai
authored andcommitted
client: improve documentation of target strings (grpc#8078)
1 parent 6615eae commit 3c89e45

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

clientconn.go

+25-5
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,26 @@ func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*ires
118118

119119
// NewClient creates a new gRPC "channel" for the target URI provided. No I/O
120120
// is performed. Use of the ClientConn for RPCs will automatically cause it to
121-
// connect. Connect may be used to manually create a connection, but for most
122-
// users this is unnecessary.
121+
// connect. The Connect method may be called to manually create a connection,
122+
// but for most users this should be unnecessary.
123123
//
124124
// The target name syntax is defined in
125-
// https://github.com/grpc/grpc/blob/master/doc/naming.md. e.g. to use dns
126-
// resolver, a "dns:///" prefix should be applied to the target.
125+
// https://github.com/grpc/grpc/blob/master/doc/naming.md. E.g. to use the dns
126+
// name resolver, a "dns:///" prefix may be applied to the target. The default
127+
// name resolver will be used if no scheme is detected, or if the parsed scheme
128+
// is not a registered name resolver. The default resolver is "dns" but can be
129+
// overridden using the resolver package's SetDefaultScheme.
130+
//
131+
// Examples:
132+
//
133+
// - "foo.googleapis.com:8080"
134+
// - "dns:///foo.googleapis.com:8080"
135+
// - "dns:///foo.googleapis.com"
136+
// - "dns:///10.0.0.213:8080"
137+
// - "dns:///%5B2001:db8:85a3:8d3:1319:8a2e:370:7348%5D:443"
138+
// - "dns://8.8.8.8/foo.googleapis.com:8080"
139+
// - "dns://8.8.8.8/foo.googleapis.com"
140+
// - "zookeeper://zk.example.com:9900/example_service"
127141
//
128142
// The DialOptions returned by WithBlock, WithTimeout,
129143
// WithReturnConnectionError, and FailOnNonTempDialError are ignored by this
@@ -872,7 +886,13 @@ func (cc *ClientConn) Target() string {
872886
return cc.target
873887
}
874888

875-
// CanonicalTarget returns the canonical target string of the ClientConn.
889+
// CanonicalTarget returns the canonical target string used when creating cc.
890+
//
891+
// This always has the form "<scheme>://[authority]/<endpoint>". For example:
892+
//
893+
// - "dns:///example.com:42"
894+
// - "dns://8.8.8.8/example.com:42"
895+
// - "unix:///path/to/socket"
876896
func (cc *ClientConn) CanonicalTarget() string {
877897
return cc.parsedTarget.String()
878898
}

0 commit comments

Comments
 (0)