Merge pull request #524 from milosgajdos83/gosssip-remove-node
Properly delete service nodes
This commit is contained in:
commit
73a8b14145
@ -115,27 +115,20 @@ func delNodes(old, del []*registry.Node) []*registry.Node {
|
|||||||
|
|
||||||
func delServices(old, del []*registry.Service) []*registry.Service {
|
func delServices(old, del []*registry.Service) []*registry.Service {
|
||||||
var services []*registry.Service
|
var services []*registry.Service
|
||||||
|
|
||||||
for _, o := range old {
|
for _, o := range old {
|
||||||
srv := new(registry.Service)
|
|
||||||
*srv = *o
|
|
||||||
|
|
||||||
var rem bool
|
var rem bool
|
||||||
|
|
||||||
for _, s := range del {
|
for _, s := range del {
|
||||||
if srv.Version == s.Version {
|
if o.Version == s.Version {
|
||||||
srv.Nodes = delNodes(srv.Nodes, s.Nodes)
|
s.Nodes = delNodes(s.Nodes, o.Nodes)
|
||||||
|
if len(s.Nodes) == 0 {
|
||||||
if len(srv.Nodes) == 0 {
|
|
||||||
rem = true
|
rem = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !rem {
|
if !rem {
|
||||||
services = append(services, srv)
|
services = append(services, o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return services
|
return services
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user