Drop clumsy timeout on discovery notifications

It's better to just let goroutines fallback to their longer retry
intervals then try to be clever here.
This commit is contained in:
Michael Schurter
2016-09-26 16:05:21 -07:00
parent 93fbc12401
commit d6b149678e

View File

@@ -1601,19 +1601,13 @@ DISCOLOOP:
c.logger.Printf("[INFO] client.consul: discovered following Servers: %s", servers)
c.servers.set(servers)
// Notify waiting rpc calls. Wait briefly in case initial rpc
// just failed but the calling goroutine isn't selecting on
// discovered yet.
const dur = 50 * time.Millisecond
timeout := time.NewTimer(dur)
// Notify waiting rpc calls. If a goroutine just failed an RPC call and
// isn't receiving on this chan yet they'll still retry eventually.
// This is a shortcircuit for the longer retry intervals.
for {
select {
case c.serversDiscoveredCh <- struct{}{}:
if !timeout.Stop() {
<-timeout.C
}
timeout.Reset(dur)
case <-timeout.C:
default:
return nil
}
}