announce retry should check the pubsub context for cancellation
This commit is contained in:
parent
0824316326
commit
2544ae7df9
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue