Use existing consul client for watcher
This commit is contained in:
		| @@ -2,6 +2,8 @@ package consul | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
|  | 	"log" | ||||||
|  | 	"os" | ||||||
| 	"sync" | 	"sync" | ||||||
|  |  | ||||||
| 	"github.com/hashicorp/consul/api" | 	"github.com/hashicorp/consul/api" | ||||||
| @@ -43,7 +45,7 @@ func newConsulWatcher(cr *consulRegistry, opts ...registry.WatchOption) (registr | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	wp.Handler = cw.handle | 	wp.Handler = cw.handle | ||||||
| 	go wp.Run(cr.Address) | 	go wp.RunWithClientAndLogger(cr.Client, log.New(os.Stderr, "", log.LstdFlags)) | ||||||
| 	cw.wp = wp | 	cw.wp = wp | ||||||
|  |  | ||||||
| 	return cw, nil | 	return cw, nil | ||||||
| @@ -208,7 +210,7 @@ func (cw *consulWatcher) handle(idx uint64, data interface{}) { | |||||||
| 		}) | 		}) | ||||||
| 		if err == nil { | 		if err == nil { | ||||||
| 			wp.Handler = cw.serviceHandler | 			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.watchers[service] = wp | ||||||
| 			cw.next <- ®istry.Result{Action: "create", Service: ®istry.Service{Name: service}} | 			cw.next <- ®istry.Result{Action: "create", Service: ®istry.Service{Name: service}} | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user