35 lines
608 B
Go
35 lines
608 B
Go
package node
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
|
|
"deevirt.fr/compute/pkg/config"
|
|
"deevirt.fr/compute/pkg/proto"
|
|
"deevirt.fr/compute/pkg/raft"
|
|
)
|
|
|
|
type Node struct {
|
|
Config *config.Config
|
|
Store *raft.Store
|
|
proto.UnimplementedNodeServer
|
|
}
|
|
|
|
func (n *Node) Alive(stream proto.Node_AliveServer) error {
|
|
for {
|
|
req, err := stream.Recv()
|
|
if err == io.EOF || err != nil {
|
|
log.Println("Client closed the connection")
|
|
return nil
|
|
}
|
|
|
|
log.Printf("Received heartbeat: %s", req.NodeId)
|
|
|
|
// On envoi les noeuds
|
|
res, _ := n.Store.Get("/nodes")
|
|
stream.Send(&proto.NodeAliveQemuResponse{
|
|
Nodes: res,
|
|
})
|
|
}
|
|
}
|