251
configConstructor tlsConfigConstructor,
252
isEnabled bool,
254
>
if !isEnabled {
255
return nil, nil
256
}
257
258
// Check if exists under a read lock first
260
>
if clientConfig, ok := s.cachedRemoteClusterClientConfig[hostname]; ok {
261
defer s.RUnlock()
262
return clientConfig, nil
263
}
264
// Not found, promote to write lock to initialize
266
>
s.Lock()
267
>
defer s.Unlock()
268
>
// Check if someone got here first while waiting for write lock
269
>
if clientConfig, ok := s.cachedRemoteClusterClientConfig[hostname]; ok {
270
return clientConfig, nil
271
}
272
273
// Load configuration
275
>
276
>
if err != nil {
277
return nil, err
278
}
279
281
>
return localConfig, nil
282
}
283