Only emit the events when actually deleting the route

This commit is contained in:
Milos Gajdos 2019-08-29 16:25:21 +01:00
parent f50bd400f8
commit 4f788c6fc7
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F

View File

@ -83,8 +83,10 @@ func (t *table) Delete(r Route) error {
return ErrRouteNotFound
}
delete(t.routes[service], sum)
go t.sendEvent(&Event{Type: Delete, Timestamp: time.Now(), Route: r})
if _, ok := t.routes[service][sum]; ok {
delete(t.routes[service], sum)
go t.sendEvent(&Event{Type: Delete, Timestamp: time.Now(), Route: r})
}
return nil
}