From cb4a2864da371e0e701f22a2f98ebb1c622ad0d6 Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Tue, 28 Jul 2020 09:01:08 +0100 Subject: [PATCH] router/registry: fix not started bug (#1877) --- router/registry/registry.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/router/registry/registry.go b/router/registry/registry.go index b585965b..5a6db4dd 100644 --- a/router/registry/registry.go +++ b/router/registry/registry.go @@ -1,7 +1,6 @@ package registry import ( - "errors" "fmt" "sort" "strings" @@ -55,6 +54,9 @@ func NewRouter(opts ...router.Option) router.Router { // create the new table, passing the fetchRoute method in as a fallback if // the table doesn't contain the result for a query. r.table = newTable(r.fetchRoutes) + + // start the router + r.start() return r } @@ -545,13 +547,6 @@ func (r *rtr) Advertise() (<-chan *router.Advert, error) { r.Lock() defer r.Unlock() - if r.running { - return nil, errors.New("cannot re-advertise, already running") - } - - // start the router - r.start() - // we're mutating the subscribers so they need to be locked also r.sub.Lock() defer r.sub.Unlock()