Skip to content

Commit

Permalink
Split the error handling from Consul Catalog (deadlock)
Browse files Browse the repository at this point in the history
  • Loading branch information
ortz authored and traefiker committed Jul 5, 2018
1 parent b183658 commit f323df4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions provider/consulcatalog/consul_catalog.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package consulcatalog

import (
"errors"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -155,14 +154,8 @@ func (p *Provider) watch(configurationChan chan<- types.ConfigMessage, stop chan
defer close(stopCh)
defer close(watchCh)

for {
select {
case <-stop:
return nil
case index, ok := <-watchCh:
if !ok {
return errors.New("consul service list nil")
}
safe.Go(func() {
for index := range watchCh {
log.Debug("List of services changed")
nodes, err := p.getNodes(index)
if err != nil {
Expand All @@ -173,6 +166,13 @@ func (p *Provider) watch(configurationChan chan<- types.ConfigMessage, stop chan
ProviderName: "consul_catalog",
Configuration: configuration,
}
}
})

for {
select {
case <-stop:
return nil
case err := <-errorCh:
return err
}
Expand Down

0 comments on commit f323df4

Please sign in to comment.