Skip to content

Commit

Permalink
announce retry should check the pubsub context for cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Mar 6, 2018
1 parent ace0e2f commit 85b3871
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,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.
Expand Down

0 comments on commit 85b3871

Please sign in to comment.