When the TTL flips to critical we should issue a delete event

This commit is contained in:
Asim 2016-05-03 18:34:57 +01:00
parent d3de45409f
commit e541d45f38

View File

@ -77,6 +77,29 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
serviceMap[key] = svc serviceMap[key] = svc
} }
var del bool
for _, check := range e.Checks {
if check.ServiceName != serviceName {
continue
}
if check.ServiceID != id {
continue
}
// delete the node
if check.Status == "critical" {
del = true
break
}
}
// if delete then skip the node
if del {
continue
}
svc.Nodes = append(svc.Nodes, &Node{ svc.Nodes = append(svc.Nodes, &Node{
Id: id, Id: id,
Address: address, Address: address,
@ -141,6 +164,7 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
cw.next <- &Result{Action: "delete", Service: delService} cw.next <- &Result{Action: "delete", Service: delService}
} }
} }
cw.next <- &Result{Action: action, Service: newService} cw.next <- &Result{Action: action, Service: newService}
} }