styx/parser/main.go

45 lines
854 B
Go
Raw Normal View History

package parser
2020-01-26 17:27:20 +01:00
import (
"encoding/json"
"io/ioutil"
"github.com/sirupsen/logrus"
"gitlab.dcso.lolcat/LABS/styx/models"
"gitlab.dcso.lolcat/LABS/styx/utils"
)
// read node recieved on kafka
// create a node in the node file
// save domains in another file with node ID
// parallel routine
// look throught domain names and if find some that exists already, create the
// edge file
const (
NodesFilename = "nodes.json"
EdgesFilename = "edges.json"
)
func ParseEvent(domains []string) {
2020-01-26 17:27:20 +01:00
nodeFile, err := ioutil.ReadFile(NodesFilename)
if err != nil {
logrus.Error(err)
}
nodeDatas := []models.Node{}
if err := json.Unmarshal(nodeFile, &nodeDatas); err != nil {
logrus.Error(err)
}
for _, node := range nodeDatas {
utils.SaveDomains(node.Data.Data.LeafCert.AllDomains)
}
// saveDomains()
// go findDomainEdges()
}
// Helpers