router/registry: fix not started bug (#1877)
This commit is contained in:
parent
f17e4fdb44
commit
cb4a2864da
@ -1,7 +1,6 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"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
|
// create the new table, passing the fetchRoute method in as a fallback if
|
||||||
// the table doesn't contain the result for a query.
|
// the table doesn't contain the result for a query.
|
||||||
r.table = newTable(r.fetchRoutes)
|
r.table = newTable(r.fetchRoutes)
|
||||||
|
|
||||||
|
// start the router
|
||||||
|
r.start()
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,13 +547,6 @@ func (r *rtr) Advertise() (<-chan *router.Advert, error) {
|
|||||||
r.Lock()
|
r.Lock()
|
||||||
defer r.Unlock()
|
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
|
// we're mutating the subscribers so they need to be locked also
|
||||||
r.sub.Lock()
|
r.sub.Lock()
|
||||||
defer r.sub.Unlock()
|
defer r.sub.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user