announce retry should check the pubsub context for cancellation

This commit is contained in:
vyzo 2018-03-06 10:02:19 +02:00 committed by Steven Allen
parent 0824316326
commit 2544ae7df9
1 changed files with 7 additions and 1 deletions

View File

@ -339,12 +339,18 @@ func (p *PubSub) announce(topic string, sub bool) {
func (p *PubSub) announceRetry(topic string, sub bool) {
time.Sleep(time.Duration(1+rand.Intn(1000)) * time.Millisecond)
p.eval <- func() {
retry := func() {
_, ok := p.myTopics[topic]
if (ok && sub) || (!ok && !sub) {
p.announce(topic, sub)
}
}
select {
case p.eval <- retry:
case <-p.ctx.Done():
}
}
// notifySubs sends a given message to all corresponding subscribers.