Skip to content

Commit

Permalink
alerting: clean up per pr reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
darwinz committed Jun 17, 2022
1 parent aa77e45 commit 59c0a57
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 24 deletions.
4 changes: 2 additions & 2 deletions internal/alerting/alerter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ func NewAlerters(cfg service.ErrorAlerting) (Alerters, error) {
return alerters, nil
}

func (s *Alerters) AlertError(e error) error {
func (s Alerters) AlertError(e error) error {
if e == nil {
return nil
}

for _, alerter := range *s {
for _, alerter := range s {
err := alerter.AlertError(e)
if err != nil {
return fmt.Errorf("alerting error: %v", err)
Expand Down
20 changes: 0 additions & 20 deletions internal/alerting/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,6 @@ func (s *Slack) AlertError(e error) error {
return nil
}

func (s *Slack) AlertWithAttachments(msg, color string, fields []slack.AttachmentField) error {
var attachment = slack.Attachment{
Fields: fields,
// color hex value, example: "#8E1600"
Color: color,
}

_, _, err := s.client.PostMessage(
s.channelID,
slack.MsgOptionText(msg, false),
slack.MsgOptionAttachments(attachment),
slack.MsgOptionAsUser(false),
)
if err != nil {
return fmt.Errorf("sending slack message: %v", err)
}

return nil
}

func (s *Slack) AuthTest() error {
if s == nil || s.client == nil {
return errors.New("slack: nil or no slack client")
Expand Down
2 changes: 1 addition & 1 deletion internal/incoming/odfi/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (s *PeriodicScheduler) tick(shard *service.Shard) error {
}

func (s *PeriodicScheduler) alertOnError(err error) {
if s == nil || len(s.alerters) == 0 {
if s == nil {
return
}
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/pipeline/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (xfagg *aggregator) notifyAboutHoliday(day *schedule.Day) {
}

func (xfagg *aggregator) alertOnError(err error) {
if xfagg == nil || len(xfagg.alerters) == 0 {
if xfagg == nil {
return
}
if err == nil {
Expand Down

0 comments on commit 59c0a57

Please sign in to comment.