Browse Source

use existing func to parse host id from topic

Abhishek Kondur 2 years ago
parent
commit
be2a730a24
2 changed files with 1 additions and 11 deletions
  1. 1 1
      mq/handlers.go
  2. 0 10
      mq/util.go

+ 1 - 1
mq/handlers.go

@@ -121,7 +121,7 @@ func UpdateNode(client mqtt.Client, msg mqtt.Message) {
 // UpdateHost  message Handler -- handles host updates from clients
 func UpdateHost(client mqtt.Client, msg mqtt.Message) {
 	go func(msg mqtt.Message) {
-		id, err := getHostID(msg.Topic())
+		id, err := getID(msg.Topic())
 		if err != nil {
 			logger.Log(1, "error getting host.ID sent on ", msg.Topic(), err.Error())
 			return

+ 0 - 10
mq/util.go

@@ -94,13 +94,3 @@ func getID(topic string) (string, error) {
 	//the last part of the topic will be the node.ID
 	return parts[count-1], nil
 }
-
-// decodes a message queue topic and returns the embedded host.ID
-func getHostID(topic string) (string, error) {
-	parts := strings.Split(topic, "/")
-	count := len(parts)
-	if count < 3 {
-		return "", fmt.Errorf("invalid topic")
-	}
-	return parts[2], nil
-}