@@ -99,7 +99,7 @@ func NewPool(config *bootstrap.Config) *Pool {
9999// expected to invoke once they are done using the client. It is safe for the
100100// caller to invoke this close function multiple times.
101101func (p * Pool ) NewClient (name string , metricsRecorder estats.MetricsRecorder ) (XDSClient , func (), error ) {
102- return p .newRefCounted (name , metricsRecorder )
102+ return p .newRefCounted (name , metricsRecorder , 0 )
103103}
104104
105105// NewClientForTesting returns an xDS client configured with the provided
@@ -126,11 +126,11 @@ func (p *Pool) NewClientForTesting(opts OptionsForTesting) (XDSClient, func(), e
126126 if opts .MetricsRecorder == nil {
127127 opts .MetricsRecorder = istats .NewMetricsRecorderList (nil )
128128 }
129- c , cancel , err := p .newRefCounted (opts .Name , opts .MetricsRecorder )
129+ c , cancel , err := p .newRefCounted (opts .Name , opts .MetricsRecorder , opts . WatchExpiryTimeout )
130130 if err != nil {
131131 return nil , nil , err
132132 }
133- c .SetWatchExpiryTimeoutForTesting (opts .WatchExpiryTimeout )
133+ // c.SetWatchExpiryTimeoutForTesting(opts.WatchExpiryTimeout)
134134 return c , cancel , nil
135135}
136136
@@ -252,7 +252,7 @@ func (p *Pool) clientRefCountedClose(name string) {
252252// newRefCounted creates a new reference counted xDS client implementation for
253253// name, if one does not exist already. If an xDS client for the given name
254254// exists, it gets a reference to it and returns it.
255- func (p * Pool ) newRefCounted (name string , metricsRecorder estats.MetricsRecorder ) (* clientImpl , func (), error ) {
255+ func (p * Pool ) newRefCounted (name string , metricsRecorder estats.MetricsRecorder , watchExpiryTimeout time. Duration ) (* clientImpl , func (), error ) {
256256 p .mu .Lock ()
257257 defer p .mu .Unlock ()
258258
@@ -275,17 +275,19 @@ func (p *Pool) newRefCounted(name string, metricsRecorder estats.MetricsRecorder
275275 c .incrRef ()
276276 return c , sync .OnceFunc (func () { p .clientRefCountedClose (name ) }), nil
277277 }
278-
279278 c , err := newClientImpl (config , metricsRecorder , name )
280279 if err != nil {
281280 return nil , nil , err
282281 }
282+ c .XDSClient .SetWatchExpiryTimeoutForTesting (watchExpiryTimeout )
283283 if logger .V (2 ) {
284284 c .logger .Infof ("Created client with name %q and bootstrap configuration:\n %s" , name , config )
285285 }
286286 p .clients [name ] = c
287287 xdsClientImplCreateHook (name )
288288
289289 logger .Infof ("xDS node ID: %s" , config .Node ().GetId ())
290- return c , sync .OnceFunc (func () { p .clientRefCountedClose (name ) }), nil
290+ return c , sync .OnceFunc (func () {
291+ p .clientRefCountedClose (name )
292+ }), nil
291293}
0 commit comments