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 { 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 // broadcast version means broadcast to all nodes
if service.Version == broadcastVersion { case broadcastVersion:
for _, node := range service.Nodes { for _, node := range service.Nodes {
// publish async // publish async
go fn(node, b) go fn(node, b)
} }
return nil
}
node := service.Nodes[rand.Int()%len(service.Nodes)] default:
// publish async // select node to publish to
go fn(node, b) node := service.Nodes[rand.Int()%len(service.Nodes)]
// publish async
go fn(node, b)
}
} }
return nil return nil