From 400f4c54db7ca0b4ecb5be09ff20159f6cb94bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Mon, 23 Sep 2024 13:56:50 +0200 Subject: [PATCH] Add NewDefaultRouter constructor (#493) --- message/router.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/message/router.go b/message/router.go index fb8199cbf..1b93e85a6 100644 --- a/message/router.go +++ b/message/router.go @@ -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{} } @@ -116,7 +128,7 @@ func NewRouter(config RouterConfig, logger watermill.LoggerAdapter) (*Router, er logger: logger, running: make(chan struct{}), - }, nil + } } type middleware struct {