in case of reload return nil
This commit is contained in:
parent
48b80dd051
commit
1321782785
@ -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,7 +345,12 @@ func (c *registrySelector) watch(w registry.Watcher) error {
|
|||||||
for {
|
for {
|
||||||
res, err := w.Next()
|
res, err := w.Next()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
select {
|
||||||
|
case <-reload:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.update(res)
|
c.update(res)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user