NewXXX always returns without error

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-08-28 12:27:52 +03:00
parent b7c0506538
commit 19e0b3a721

View File

@ -30,7 +30,7 @@ type rtr struct {
}
// NewRouter creates new router and returns it
func NewRouter(opts ...router.Option) (router.Router, error) {
func NewRouter(opts ...router.Option) router.Router {
// get default options
options := router.DefaultOptions()
@ -45,17 +45,13 @@ func NewRouter(opts ...router.Option) (router.Router, error) {
initChan: make(chan bool),
}
if options.Registry == nil {
return nil, fmt.Errorf("registry not set")
}
// 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.lookup)
// start the router
r.start()
return r, nil
return r
}
// Init initializes router with given options
@ -66,6 +62,10 @@ func (r *rtr) Init(opts ...router.Option) error {
}
r.Unlock()
if r.options.Registry == nil {
return fmt.Errorf("registry not set")
}
// push a message to the init chan so the watchers
// can reset in the case the registry was changed
go func() {