From 6045e5430f362abc76c6d73d099ded13d416a9a6 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Tue, 25 Jul 2023 20:59:20 +0530 Subject: [PATCH] chore: rename events/consumers.go -> events/event_consumer.go --- events/{consumers.go => event_consumer.go} | 20 ++------------------ events/events.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) rename events/{consumers.go => event_consumer.go} (89%) diff --git a/events/consumers.go b/events/event_consumer.go similarity index 89% rename from events/consumers.go rename to events/event_consumer.go index fbc2fe849..d03170bfd 100644 --- a/events/consumers.go +++ b/events/event_consumer.go @@ -130,15 +130,14 @@ func (e *EventConsumer) listenToPostgresNotify(pgNotify chan bool) { if err != nil { return fmt.Errorf("error listening to database notifications: %v", err) } - logger.Infof("listening to database notifications") + logger.Debugf("listening to database notifications") for { - notification, err := conn.Conn().WaitForNotification(ctx) + _, err := conn.Conn().WaitForNotification(ctx) if err != nil { return fmt.Errorf("error listening to database notifications: %v", err) } - logger.Tracef("Received database notification: %+v", notification) pgNotify <- true } } @@ -182,18 +181,3 @@ func (e *EventConsumer) Listen() { } } } - -func StartConsumers(gormDB *gorm.DB, config Config) { - allConsumers := []EventConsumer{ - NewTeamConsumer(gormDB), - NewNotificationConsumer(gormDB), - NewResponderConsumer(gormDB), - } - if config.UpstreamPush.Valid() { - allConsumers = append(allConsumers, NewUpstreamPushConsumer(gormDB, config)) - } - - for _, c := range allConsumers { - go c.Listen() - } -} diff --git a/events/events.go b/events/events.go index 55e0789f2..598179bfc 100644 --- a/events/events.go +++ b/events/events.go @@ -4,6 +4,7 @@ import ( "time" "github.com/flanksource/incident-commander/api" + "gorm.io/gorm" ) const ( @@ -46,3 +47,18 @@ const ( type Config struct { UpstreamPush api.UpstreamConfig } + +func StartConsumers(gormDB *gorm.DB, config Config) { + allConsumers := []EventConsumer{ + NewTeamConsumer(gormDB), + NewNotificationConsumer(gormDB), + NewResponderConsumer(gormDB), + } + if config.UpstreamPush.Valid() { + allConsumers = append(allConsumers, NewUpstreamPushConsumer(gormDB, config)) + } + + for _, c := range allConsumers { + go c.Listen() + } +}