package main import ( "fmt" "time" "context" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" pb "FRMS/internal/pkg/grpc" ) var Reactors = []string{"192.1.168.156","192.1.168.81"} func main() { // lets get this bread for _, r := range Reactors { go pingReactors(r) } for true { time.Sleep(10 * time.Second) } } func pingReactors(id string) { fmt.Println(id) var opts []grpc.DialOption opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) conn, err := grpc.Dial(id+":2000",opts...) if err != nil { fmt.Println(err) } defer conn.Close() client := pb.NewMonitoringClient(conn) for true{ resp, err := client.SensorStatusHandler(context.Background(), &pb.SensorStatusRequest{}) if err != nil { fmt.Println(err) } fmt.Printf("Reactor %v active\n", resp.Id) time.Sleep(3 * time.Second) } }