From f50bd400f89f7c62bfe82028a2c2ec4dcbc13598 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Thu, 29 Aug 2019 16:21:30 +0100 Subject: [PATCH 1/2] Only emit event if Update actually happens --- router/table.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/router/table.go b/router/table.go index 42a1be47..c35f9a89 100644 --- a/router/table.go +++ b/router/table.go @@ -105,8 +105,10 @@ func (t *table) Update(r Route) error { return nil } - t.routes[service][sum] = r - go t.sendEvent(&Event{Type: Update, Timestamp: time.Now(), Route: r}) + if _, ok := t.routes[service][sum]; !ok { + t.routes[service][sum] = r + go t.sendEvent(&Event{Type: Update, Timestamp: time.Now(), Route: r}) + } return nil } From 4f788c6fc7ab036de4c293c691b68a46cd4e88d8 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Thu, 29 Aug 2019 16:25:21 +0100 Subject: [PATCH 2/2] Only emit the events when actually deleting the route --- router/table.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/router/table.go b/router/table.go index c35f9a89..c61b560c 100644 --- a/router/table.go +++ b/router/table.go @@ -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 }