Fix ticker leak in campaign manager message push
This commit is contained in:
parent
fd044f4cb6
commit
c2613d1030
|
@ -157,9 +157,12 @@ func (m *Manager) AddMessenger(msg messenger.Messenger) error {
|
||||||
|
|
||||||
// PushMessage pushes a Message to be sent out by the workers.
|
// PushMessage pushes a Message to be sent out by the workers.
|
||||||
func (m *Manager) PushMessage(msg Message) error {
|
func (m *Manager) PushMessage(msg Message) error {
|
||||||
|
t := time.NewTicker(time.Second * 3)
|
||||||
|
defer t.Stop()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case m.msgQueue <- msg:
|
case m.msgQueue <- msg:
|
||||||
case <-time.After(time.Second * 3):
|
case <-t.C:
|
||||||
m.logger.Println("message push timed out: %'s'", msg.Subject)
|
m.logger.Println("message push timed out: %'s'", msg.Subject)
|
||||||
return errors.New("message push timed out")
|
return errors.New("message push timed out")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue