Skip to content

Commit

Permalink
Fix ticker leak in campaign manager message push
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jul 6, 2020
1 parent fd044f4 commit c2613d1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,12 @@ func (m *Manager) AddMessenger(msg messenger.Messenger) error {

// PushMessage pushes a Message to be sent out by the workers.
func (m *Manager) PushMessage(msg Message) error {
t := time.NewTicker(time.Second * 3)
defer t.Stop()

select {
case m.msgQueue <- msg:
case <-time.After(time.Second * 3):
case <-t.C:
m.logger.Println("message push timed out: %'s'", msg.Subject)
return errors.New("message push timed out")
}
Expand Down

0 comments on commit c2613d1

Please sign in to comment.