mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-07 13:44:17 +08:00
use existing func to parse host id from topic
This commit is contained in:
parent
9a9eaec3d4
commit
be2a730a24
2 changed files with 1 additions and 11 deletions
|
@ -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
|
||||
|
|
10
mq/util.go
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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue