package node import ( "encoding/json" "fmt" "io" "log" "deevirt.fr/compute/pkg/config" "deevirt.fr/compute/pkg/proto" "deevirt.fr/compute/pkg/raft" "deevirt.fr/compute/pkg/schema" ) type Node struct { Config *config.Config Store *raft.Store proto.UnimplementedNodeServer } func (n *Node) Alive(stream proto.Node_AliveServer) error { println("Alive") for { req, err := stream.Recv() if err == io.EOF || err != nil { log.Println("Client closed the connection") return nil } log.Printf("Received heartbeat: %v", req) cluster := schema.NodeStore{} println("on reçit une demande") res, _ := n.Store.Get("/etc/libvirt/cluster") json.Unmarshal(res, &cluster) fmt.Printf("%v\n", res) cluster[n.Config.NodeID].LastUpdate = req.Timestamp d, _ := json.Marshal(cluster) n.Store.Set("/etc/libvirt/cluster", d) stream.Send(&proto.NodeAliveQemuResponse{ Nodes: res, }) } }