You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
970 B
Go

package main
3 years ago
import (
"fmt"
"time"
"context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
pb "FRMS/internal/pkg/grpc"
3 years ago
)
var Reactors = []string{"192.1.168.156"}
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.NewCoordinatorClient(conn)
for true{
resp, err := client.PingHandler(context.Background(), &pb.PingRequest{})
if err != nil {
fmt.Println(err)
}
fmt.Printf("Reactor %v active\n", resp.Id)
time.Sleep(3 * time.Second)
}
}