Only saving objects that have an ID

This commit is contained in:
Christopher Talib 2020-01-23 15:01:08 +01:00
parent 2a04e01457
commit 01f3e3ca1e
2 changed files with 5 additions and 8 deletions

View file

@ -3,6 +3,7 @@ package broker
import (
"context"
"encoding/json"
"fmt"
"time"
"github.com/segmentio/kafka-go"
@ -51,11 +52,10 @@ func ReadEventFromKafka() {
}
var node models.Node
json.Unmarshal(m.Value, &node)
utils.SaveNode(&node)
if len(node.ID) != 0 {
fmt.Println(node)
utils.SaveNode(&node)
}
}
}

View file

@ -28,7 +28,6 @@ func main() {
if err != nil {
panic(err)
}
utils.SaveNode(node)
broker.SendEventToKafka(Conn, *node)
}
@ -37,5 +36,3 @@ func main() {
}
}
}
// Helpers