in case of reload return nil

This commit is contained in:
Asim Aslam 2019-01-19 10:20:16 +00:00
parent 48b80dd051
commit 1321782785

View File

@ -326,12 +326,16 @@ func (c *registrySelector) run(name string) {
func (c *registrySelector) watch(w registry.Watcher) error { func (c *registrySelector) watch(w registry.Watcher) error {
defer w.Stop() defer w.Stop()
// reload chan
reload := make(chan bool, 1)
// manage this loop // manage this loop
go func() { go func() {
// wait for exit or reload signal // wait for exit or reload signal
select { select {
case <-c.exit: case <-c.exit:
case <-c.reload: case <-c.reload:
reload <- true
} }
// stop the watcher // stop the watcher
@ -341,8 +345,13 @@ func (c *registrySelector) watch(w registry.Watcher) error {
for { for {
res, err := w.Next() res, err := w.Next()
if err != nil { if err != nil {
select {
case <-reload:
return nil
default:
return err return err
} }
}
c.update(res) c.update(res)
} }
} }