1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00
This commit is contained in:
lubaoquan 2019-09-30 10:36:43 +08:00
parent 9ec27392de
commit 866631df1d
2 changed files with 28 additions and 26 deletions

View File

@ -163,7 +163,7 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
// it's an update rather than creation
if len(nodes) > 0 {
delService := oldService
delService := registry.CopyService(oldService)
delService.Nodes = nodes
cw.next <- &registry.Result{Action: "delete", Service: delService}
}

View File

@ -48,10 +48,8 @@ func delNodes(old, del []*Node) []*Node {
return nodes
}
// Copy makes a copy of services
func Copy(current []*Service) []*Service {
services := make([]*Service, len(current))
for i, service := range current {
// CopyService make a copy of service
func CopyService(service *Service) *Service {
// copy service
s := new(Service)
*s = *service
@ -73,11 +71,15 @@ func Copy(current []*Service) []*Service {
eps[j] = e
}
s.Endpoints = eps
// append service
services[i] = s
return s
}
// Copy makes a copy of services
func Copy(current []*Service) []*Service {
services := make([]*Service, len(current))
for i, service := range current {
services[i] = CopyService(service)
}
return services
}