we need to not return after processing broadcast, still gotta process the other queues

This commit is contained in:
Asim 2016-11-21 15:58:39 +01:00
parent 0be3256d25
commit 8873e6ad08

View File

@ -375,18 +375,26 @@ func (h *httpBroker) Publish(topic string, msg *Message, opts ...PublishOption)
}
for _, service := range s {
// only process if we have nodes
if len(service.Nodes) == 0 {
continue
}
switch service.Version {
// broadcast version means broadcast to all nodes
if service.Version == broadcastVersion {
case broadcastVersion:
for _, node := range service.Nodes {
// publish async
go fn(node, b)
}
return nil
}
node := service.Nodes[rand.Int()%len(service.Nodes)]
// publish async
go fn(node, b)
default:
// select node to publish to
node := service.Nodes[rand.Int()%len(service.Nodes)]
// publish async
go fn(node, b)
}
}
return nil