Don't block the event loop if the subscriber is too slow

Closes #69
This commit is contained in:
vyzo 2018-03-06 11:50:16 +02:00
parent e48c6f5d4a
commit d5d886d853
1 changed files with 5 additions and 1 deletions

View File

@ -326,7 +326,11 @@ func (p *PubSub) notifySubs(msg *pb.Message) {
for _, topic := range msg.GetTopicIDs() {
subs := p.myTopics[topic]
for f := range subs {
f.ch <- &Message{msg}
select {
case f.ch <- &Message{msg}:
default:
log.Errorf("Can't deliver message to subscription for topic %s; subscriber too slow", topic)
}
}
}
}