Merge pull request #800 from kordenlu/master
fix rcache node overwrited issue
This commit is contained in:
commit
1322fb0d9d
@ -163,7 +163,7 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
|
|||||||
|
|
||||||
// it's an update rather than creation
|
// it's an update rather than creation
|
||||||
if len(nodes) > 0 {
|
if len(nodes) > 0 {
|
||||||
delService := oldService
|
delService := registry.CopyService(oldService)
|
||||||
delService.Nodes = nodes
|
delService.Nodes = nodes
|
||||||
cw.next <- ®istry.Result{Action: "delete", Service: delService}
|
cw.next <- ®istry.Result{Action: "delete", Service: delService}
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,8 @@ func delNodes(old, del []*Node) []*Node {
|
|||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy makes a copy of services
|
// CopyService make a copy of service
|
||||||
func Copy(current []*Service) []*Service {
|
func CopyService(service *Service) *Service {
|
||||||
services := make([]*Service, len(current))
|
|
||||||
for i, service := range current {
|
|
||||||
// copy service
|
// copy service
|
||||||
s := new(Service)
|
s := new(Service)
|
||||||
*s = *service
|
*s = *service
|
||||||
@ -73,11 +71,15 @@ func Copy(current []*Service) []*Service {
|
|||||||
eps[j] = e
|
eps[j] = e
|
||||||
}
|
}
|
||||||
s.Endpoints = eps
|
s.Endpoints = eps
|
||||||
|
return s
|
||||||
// append service
|
|
||||||
services[i] = 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
|
return services
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user