Skip to content

Commit

Permalink
Merge pull request #470 from flanksource/fix/event-consumers
Browse files Browse the repository at this point in the history
fix: event consumer
  • Loading branch information
moshloop authored Aug 2, 2023
2 parents fa1a10d + b918e01 commit 151b0de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions events/event_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
4 changes: 2 additions & 2 deletions events/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ func addNotificationEvent(ctx *api.Context, event api.Event) error {
}

expressionRunner := pkgNotification.ExpressionRunner{
ResourceID: n.TeamID.String(),
ResourceType: "teams",
ResourceID: id,
ResourceType: "notification",
CelEnv: celEnv,
}

Expand Down

0 comments on commit 151b0de

Please sign in to comment.