@@ -192,7 +192,7 @@ var (
192192 defaultRangeLeaseDuration = envutil .EnvOrDefaultDuration (
193193 "COCKROACH_RANGE_LEASE_DURATION" , 6 * time .Second )
194194
195- // defaultRPCHeartbeatTimeout is the default RPC heartbeat timeout. It is set
195+ // DefaultRPCHeartbeatTimeout is the default RPC heartbeat timeout. It is set
196196 // very high at 3 * NetworkTimeout for several reasons: the gRPC transport may
197197 // need to complete a dial/handshake before sending the heartbeat, the
198198 // heartbeat has occasionally been seen to require 3 RTTs even post-dial (for
@@ -212,7 +212,7 @@ var (
212212 // heartbeats and reduce this to NetworkTimeout (plus DialTimeout for the
213213 // initial heartbeat), see:
214214 // https://github.com/cockroachdb/cockroach/issues/93397.
215- defaultRPCHeartbeatTimeout = 3 * NetworkTimeout
215+ DefaultRPCHeartbeatTimeout = 3 * NetworkTimeout
216216
217217 // defaultRaftTickInterval is the default resolution of the Raft timer.
218218 defaultRaftTickInterval = envutil .EnvOrDefaultDuration (
@@ -341,10 +341,13 @@ type Config struct {
341341 // Addr is the address the server is listening on.
342342 Addr string
343343
344- // AdvertiseAddr is the address advertised by the server to other nodes
345- // in the cluster. It should be reachable by all other nodes and should
346- // route to an interface that Addr is listening on.
347- AdvertiseAddr string
344+ // AdvertiseAddrH contains the address advertised by the server to
345+ // other nodes in the cluster. It should be reachable by all other
346+ // nodes and should route to an interface that Addr is listening on.
347+ //
348+ // It is set after the server instance has been created, when the
349+ // network listeners are being set up.
350+ AdvertiseAddrH
348351
349352 // ClusterName is the name used as a sanity check when a node joins
350353 // an uninitialized cluster, or when an uninitialized node joins an
@@ -367,9 +370,12 @@ type Config struct {
367370 // This is used if SplitListenSQL is set to true.
368371 SQLAddr string
369372
370- // SQLAdvertiseAddr is the advertised SQL address.
373+ // SQLAdvertiseAddrH contains the advertised SQL address.
371374 // This is computed from SQLAddr if specified otherwise Addr.
372- SQLAdvertiseAddr string
375+ //
376+ // It is set after the server instance has been created, when the
377+ // network listeners are being set up.
378+ SQLAdvertiseAddrH
373379
374380 // SocketFile, if non-empty, sets up a TLS-free local listener using
375381 // a unix datagram socket at the specified path for SQL clients.
@@ -382,9 +388,12 @@ type Config struct {
382388 // DisableTLSForHTTP, if set, disables TLS for the HTTP listener.
383389 DisableTLSForHTTP bool
384390
385- // HTTPAdvertiseAddr is the advertised HTTP address.
391+ // HTTPAdvertiseAddrH contains the advertised HTTP address.
386392 // This is computed from HTTPAddr if specified otherwise Addr.
387- HTTPAdvertiseAddr string
393+ //
394+ // It is set after the server instance has been created, when the
395+ // network listeners are being set up.
396+ HTTPAdvertiseAddrH
388397
389398 // RPCHeartbeatInterval controls how often Ping requests are sent on peer
390399 // connections to determine connection health and update the local view of
@@ -421,6 +430,21 @@ type Config struct {
421430 LocalityAddresses []roachpb.LocalityAddress
422431}
423432
433+ // AdvertiseAddr is the type of the AdvertiseAddr field in Config.
434+ type AdvertiseAddrH struct {
435+ AdvertiseAddr string
436+ }
437+
438+ // SQLAdvertiseAddr is the type of the SQLAdvertiseAddr field in Config.
439+ type SQLAdvertiseAddrH struct {
440+ SQLAdvertiseAddr string
441+ }
442+
443+ // HTTPAdvertiseAddr is the type of the HTTPAdvertiseAddr field in Config.
444+ type HTTPAdvertiseAddrH struct {
445+ HTTPAdvertiseAddr string
446+ }
447+
424448// HistogramWindowInterval is used to determine the approximate length of time
425449// that individual samples are retained in in-memory histograms. Currently,
426450// it is set to the arbitrary length of six times the Metrics sample interval.
@@ -455,7 +479,7 @@ func (cfg *Config) InitDefaults() {
455479 cfg .SocketFile = ""
456480 cfg .SSLCertsDir = DefaultCertsDirectory
457481 cfg .RPCHeartbeatInterval = PingInterval
458- cfg .RPCHeartbeatTimeout = defaultRPCHeartbeatTimeout
482+ cfg .RPCHeartbeatTimeout = DefaultRPCHeartbeatTimeout
459483 cfg .ClusterName = ""
460484 cfg .DisableClusterNameVerification = false
461485 cfg .ClockDevicePath = ""
0 commit comments