Skip to content

Commit

Permalink
Merge 5cd83e1 into 4eb0559
Browse files Browse the repository at this point in the history
  • Loading branch information
yesAnd92 authored Nov 2, 2023
2 parents 4eb0559 + 5cd83e1 commit 6fde0a8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion clients/naming_client/naming_cache/subscribe_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ func (ed *SubscribeCallback) AddCallbackFunc(serviceName string, clusters string
var funcSlice []*func(services []model.Instance, err error)
old, ok := ed.callbackFuncMap.Get(key)
if ok {
funcSlice = append(funcSlice, old.([]*func(services []model.Instance, err error))...)
for _, funcItem := range old.([]*func(services []model.Instance, err error)) {
if funcItem != callbackFunc {
funcSlice = append(funcSlice, funcItem)
}
}
}
funcSlice = append(funcSlice, callbackFunc)
ed.callbackFuncMap.Set(key, funcSlice)
Expand Down Expand Up @@ -79,6 +83,9 @@ func (ed *SubscribeCallback) ServiceChanged(cacheKey string, service *model.Serv
(*funcItem)(service.Hosts, errors.New("[client.Subscribe] subscribe failed,hosts is empty"))
continue
}
if *funcItem == nil {
continue
}
(*funcItem)(service.Hosts, nil)
}
}
Expand Down

0 comments on commit 6fde0a8

Please sign in to comment.