Skip to content

Commit

Permalink
🔊 Log an error and continue if an integration fails to send
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jun 7, 2023
1 parent 3f3521f commit a9a5bf4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 2 additions & 6 deletions internal/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ func (d *Domain) NotifyThreshold() error {
for _, threshold := range viper.GetIntSlice("threshold") {
if d.TriggeredThreshold != threshold && daysLeft <= threshold {
msg := message.NewThresholdMessage(d.Name, daysLeft)
if err := integration.Send(msg); err != nil {
return err
}
integration.Send(msg)
d.TriggeredThreshold = threshold
break
}
Expand All @@ -97,9 +95,7 @@ func (d *Domain) NotifyStatusChange() error {

if len(changes) > 0 {
msg := message.NewStatusChangedMessage(d.Name, changes)
if err := integration.Send(msg); err != nil {
return err
}
integration.Send(msg)
}
}
return nil
Expand Down
7 changes: 3 additions & 4 deletions internal/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ func Setup() error {
return nil
}

func Send(message string) error {
for _, integration := range Default {
func Send(message string) {
for name, integration := range Default {
if err := integration.Send(message); err != nil {
return err
log.WithField("integration", name).Error(err)
}
}
return nil
}

func Get(key string) Integration {
Expand Down

0 comments on commit a9a5bf4

Please sign in to comment.