Move the metadata parsing code to node.go
This commit is contained in:
parent
0e799d6074
commit
b0bfeb1f8e
13
main.go
13
main.go
|
@ -66,18 +66,7 @@ func main() {
|
|||
for {
|
||||
select {
|
||||
case rawNodes := <-nodec:
|
||||
logrus.Info("cluster members:\n")
|
||||
nodes := make([]node, 0)
|
||||
for _, node := range rawNodes {
|
||||
meta, err := decodeNodeMeta(node.Meta)
|
||||
if err != nil {
|
||||
logrus.Warnf("\t addr: %s, could not decode metadata", node.Addr)
|
||||
continue
|
||||
}
|
||||
node.nodeMeta = meta
|
||||
nodes = append(nodes, node)
|
||||
logrus.Infof("\taddr: %s, overlay: %s, pubkey: %s", node.Addr, node.OverlayAddr, node.PubKey)
|
||||
}
|
||||
nodes := parseNodesMeta(rawNodes)
|
||||
if err := wg.setUpInterface(nodes); err != nil {
|
||||
logrus.WithError(err).Error("could not up interface")
|
||||
wg.downInterface()
|
||||
|
|
16
node.go
16
node.go
|
@ -49,3 +49,19 @@ func decodeNodeMeta(b []byte) (nodeMeta, error) {
|
|||
}
|
||||
return nm, nil
|
||||
}
|
||||
|
||||
func parseNodesMeta(rawNodes []node) []node {
|
||||
logrus.Info("cluster members:\n")
|
||||
nodes := make([]node, 0)
|
||||
for _, node := range rawNodes {
|
||||
meta, err := decodeNodeMeta(node.Meta)
|
||||
if err != nil {
|
||||
logrus.Warnf("\t addr: %s, could not decode metadata", node.Addr)
|
||||
continue
|
||||
}
|
||||
node.nodeMeta = meta
|
||||
nodes = append(nodes, node)
|
||||
logrus.Infof("\taddr: %s, overlay: %s, pubkey: %s", node.Addr, node.OverlayAddr, node.PubKey)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue