···303303 if message == nil {
304304 continue
305305 }
306306- // TODO: this can be done in a go routine because once we've got the message from the publisher, the publisher
307307- // doesn't need to wait for us to send the message to all peers
308306309309- topic := s.getTopic(message.topic)
310310- if topic != nil {
311311- topic.sendMessageToSubscribers(message.data)
312312- }
307307+ // sending messages to the subscribers can be done async because the publisher doesn't need to wait for
308308+ // subscribers to be sent the message
309309+ go func() {
310310+ topic := s.getTopic(message.topic)
311311+ if topic != nil {
312312+ topic.sendMessageToSubscribers(message.data)
313313+ }
314314+ }()
313315 }
314316}
315317