1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00

fix(cache): only watch calling service in registry (#2273)

This commit is contained in:
Kurisu_Amatist 2021-09-19 17:40:21 +08:00 committed by GitHub
parent 00d819a199
commit efd4ef0e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -180,7 +180,7 @@ func (c *cache) get(service string) ([]*registry.Service, error) {
// only kick it off if not running // only kick it off if not running
if !c.running { if !c.running {
go c.run() go c.run(service)
} }
c.Unlock() c.Unlock()
@ -316,7 +316,7 @@ func (c *cache) update(res *registry.Result) {
// run starts the cache watcher loop // run starts the cache watcher loop
// it creates a new watcher if there's a problem // it creates a new watcher if there's a problem
func (c *cache) run() { func (c *cache) run(service string) {
c.Lock() c.Lock()
c.running = true c.running = true
c.Unlock() c.Unlock()
@ -342,7 +342,7 @@ func (c *cache) run() {
time.Sleep(time.Duration(j) * time.Millisecond) time.Sleep(time.Duration(j) * time.Millisecond)
// create new watcher // create new watcher
w, err := c.Registry.Watch() w, err := c.Registry.Watch(registry.WatchService(service))
if err != nil { if err != nil {
if c.quit() { if c.quit() {
return return