Merge pull request #478 from sneat/fix-watcher-across-datacenters

Use existing consul client for watcher
This commit is contained in:
Asim Aslam 2019-05-16 08:12:40 +01:00 committed by GitHub
commit dc5ec0cdb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,8 @@ package consul
import (
"errors"
"log"
"os"
"sync"
"github.com/hashicorp/consul/api"
@ -43,7 +45,7 @@ func newConsulWatcher(cr *consulRegistry, opts ...registry.WatchOption) (registr
}
wp.Handler = cw.handle
go wp.Run(cr.Address)
go wp.RunWithClientAndLogger(cr.Client, log.New(os.Stderr, "", log.LstdFlags))
cw.wp = wp
return cw, nil
@ -208,7 +210,7 @@ func (cw *consulWatcher) handle(idx uint64, data interface{}) {
})
if err == nil {
wp.Handler = cw.serviceHandler
go wp.Run(cw.r.Address)
go wp.RunWithClientAndLogger(cw.r.Client, log.New(os.Stderr, "", log.LstdFlags))
cw.watchers[service] = wp
cw.next <- &registry.Result{Action: "create", Service: &registry.Service{Name: service}}
}