From 8b2223dd6befc12f619512b6cc2243c3e900791a Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Wed, 2 Aug 2023 17:18:35 +0545 Subject: [PATCH 1/2] fix: event consumer --- events/event_consumer.go | 5 +++-- events/events.go | 4 ++-- events/notifications.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/events/event_consumer.go b/events/event_consumer.go index af8793a07..69446a7d7 100644 --- a/events/event_consumer.go +++ b/events/event_consumer.go @@ -4,10 +4,11 @@ import ( "context" "errors" "fmt" - "github.com/sethvargo/go-retry" "sync" "time" + "github.com/sethvargo/go-retry" + "github.com/flanksource/commons/logger" "github.com/flanksource/incident-commander/api" "github.com/flanksource/incident-commander/db" @@ -163,7 +164,7 @@ func (e *EventConsumer) listenToPostgresNotify(pgNotify chan bool) { } func (e *EventConsumer) Listen() { - logger.Infof("Started listening for database notify events") + logger.Infof("Started listening for database notify events: %v", e.WatchEvents) if err := e.Validate(); err != nil { logger.Fatalf("Error starting event consumer: %v", err) diff --git a/events/events.go b/events/events.go index 5289fd3f1..4dd16a5bf 100644 --- a/events/events.go +++ b/events/events.go @@ -63,13 +63,13 @@ func StartConsumers(gormDB *gorm.DB, config Config) { } uniqWatchEvents := set.New[string]() - for _, c := range allConsumers { + for i, c := range allConsumers { for _, we := range c.WatchEvents { if uniqWatchEvents.Contains(we) { logger.Fatalf("Error starting consumers: event[%s] has multiple consumers", we) } } uniqWatchEvents.Add(c.WatchEvents...) - go c.Listen() + go allConsumers[i].Listen() } } diff --git a/events/notifications.go b/events/notifications.go index f65520969..9231d8a79 100644 --- a/events/notifications.go +++ b/events/notifications.go @@ -251,7 +251,7 @@ func addNotificationEvent(ctx *api.Context, event api.Event) error { } expressionRunner := pkgNotification.ExpressionRunner{ - ResourceID: n.TeamID.String(), + ResourceID: id, ResourceType: "teams", CelEnv: celEnv, } From b918e01fc1a1dca2dddac6f21369a07f08329e27 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Wed, 2 Aug 2023 17:28:05 +0545 Subject: [PATCH 2/2] chore: typo --- events/notifications.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/notifications.go b/events/notifications.go index 9231d8a79..0f6bd5054 100644 --- a/events/notifications.go +++ b/events/notifications.go @@ -252,7 +252,7 @@ func addNotificationEvent(ctx *api.Context, event api.Event) error { expressionRunner := pkgNotification.ExpressionRunner{ ResourceID: id, - ResourceType: "teams", + ResourceType: "notification", CelEnv: celEnv, }