Making keepclient.RefreshServiceDiscovery asynchronous didn't work
out: tests rely on it to ensure old services won't be used.
Instead, speed things up a bit by refreshing all known clients'
service lists concurrently instead of serially.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>
func RefreshServiceDiscovery() {
svcListCacheMtx.Lock()
defer svcListCacheMtx.Unlock()
+ var wg sync.WaitGroup
for _, ent := range svcListCache {
- select {
- case ent.clear <- struct{}{}:
- default:
- }
+ wg.Add(1)
+ go func() {
+ ent.clear <- struct{}{}
+ wg.Done()
+ }()
}
+ wg.Wait()
}
// ClearCacheOnSIGHUP installs a signal handler that calls
arv := *kc.Arvados
cacheEnt = cachedSvcList{
latest: make(chan svcList),
- clear: make(chan struct{}, 1),
+ clear: make(chan struct{}),
arv: &arv,
}
go cacheEnt.poll()