fix divide by zero bug

This commit is contained in:
Asim Aslam 2019-10-19 08:11:05 +01:00
parent d3140c0fc2
commit a89d1edc41

View File

@ -560,11 +560,6 @@ func (h *httpBroker) Publish(topic string, msg *Message, opts ...PublishOption)
srv := func(s []*registry.Service, b []byte) {
for _, service := range s {
// only process if we have nodes
if len(service.Nodes) == 0 {
continue
}
var nodes []*registry.Node
for _, node := range service.Nodes {
@ -581,6 +576,11 @@ func (h *httpBroker) Publish(topic string, msg *Message, opts ...PublishOption)
nodes = append(nodes, node)
}
// only process if we have nodes
if len(nodes) == 0 {
continue
}
switch service.Version {
// broadcast version means broadcast to all nodes
case broadcastVersion: