fix divide by zero bug
This commit is contained in:
		| @@ -560,11 +560,6 @@ func (h *httpBroker) Publish(topic string, msg *Message, opts ...PublishOption) | |||||||
|  |  | ||||||
| 	srv := func(s []*registry.Service, b []byte) { | 	srv := func(s []*registry.Service, b []byte) { | ||||||
| 		for _, service := range s { | 		for _, service := range s { | ||||||
| 			// only process if we have nodes |  | ||||||
| 			if len(service.Nodes) == 0 { |  | ||||||
| 				continue |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			var nodes []*registry.Node | 			var nodes []*registry.Node | ||||||
|  |  | ||||||
| 			for _, node := range service.Nodes { | 			for _, node := range service.Nodes { | ||||||
| @@ -581,6 +576,11 @@ func (h *httpBroker) Publish(topic string, msg *Message, opts ...PublishOption) | |||||||
| 				nodes = append(nodes, node) | 				nodes = append(nodes, node) | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | 			// only process if we have nodes | ||||||
|  | 			if len(nodes) == 0 { | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			switch service.Version { | 			switch service.Version { | ||||||
| 			// broadcast version means broadcast to all nodes | 			// broadcast version means broadcast to all nodes | ||||||
| 			case broadcastVersion: | 			case broadcastVersion: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user