Skip to content

Commit

Permalink
Add NewDefaultRouter constructor (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
m110 authored Sep 23, 2024
1 parent efb5340 commit 400f4c5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion message/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ func NewRouter(config RouterConfig, logger watermill.LoggerAdapter) (*Router, er
return nil, errors.Wrap(err, "invalid config")
}

return newRouter(config, logger), nil
}

// NewDefaultRouter creates a new Router with default configuration.
func NewDefaultRouter(logger watermill.LoggerAdapter) *Router {
config := RouterConfig{}
config.setDefaults()

return newRouter(config, logger)
}

func newRouter(config RouterConfig, logger watermill.LoggerAdapter) *Router {
if logger == nil {
logger = watermill.NopLogger{}
}
Expand All @@ -116,7 +128,7 @@ func NewRouter(config RouterConfig, logger watermill.LoggerAdapter) (*Router, er
logger: logger,

running: make(chan struct{}),
}, nil
}
}

type middleware struct {
Expand Down

0 comments on commit 400f4c5

Please sign in to comment.