diff --git a/postq/pg/router.go b/postq/pg/router.go index 3072e096..7dd72a72 100644 --- a/postq/pg/router.go +++ b/postq/pg/router.go @@ -36,12 +36,13 @@ func (t *notifyRouter) WithRouteExtractor(routeExtractor routeExtractorFn) *noti return t } -// RegisterRoutes creates a single channel for the given routes and returns it. -func (t *notifyRouter) RegisterRoutes(routes ...string) <-chan string { - // If any of the routes already has a channel, we use that - // for all the routes. - // Caution: The caller needs to ensure that the route - // groups do not overlap. +// GetOrCreateChannel creates a single channel for the given routes. +// +// If any of the routes already has a channel, we use that existing for all the routes. +// +// Caution: The caller needs to ensure that the route +// groups do not overlap. +func (t *notifyRouter) GetOrCreateChannel(routes ...string) <-chan string { pgNotifyChannel := make(chan string) for _, we := range routes { if existing, ok := t.registry[we]; ok { diff --git a/postq/pg/router_test.go b/postq/pg/router_test.go index f480d62c..0b9e430d 100644 --- a/postq/pg/router_test.go +++ b/postq/pg/router_test.go @@ -15,8 +15,8 @@ func TestPGRouter(t *testing.T) { }() // Two subscribers - alpha := r.RegisterRoutes("alphaA", "alphaB") - beta := r.RegisterRoutes("beta") + alpha := r.GetOrCreateChannel("alphaA", "alphaB") + beta := r.GetOrCreateChannel("beta") var alphaCount, betaCount int timeout := time.NewTimer(time.Second * 3)