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.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"context"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
pb "FRMS/internal/pkg/grpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
fmt.Println("running")
|
|
|
|
lis, err := net.Listen("tcp", "192.1.168.156:2000")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
grpcServer := grpc.NewServer()
|
|
|
|
pb.RegisterCoordinatorServer(grpcServer, newServer())
|
|
|
|
grpcServer.Serve(lis)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newServer() *coordinatorServer {
|
|
|
|
s := &coordinatorServer{}
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type coordinatorServer struct {
|
|
|
|
pb.UnimplementedCoordinatorServer
|
|
|
|
id string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *coordinatorServer) PingHandler(ctx context.Context, ping *pb.PingRequest) (*pb.PingResponse, error) {
|
|
|
|
return &pb.PingResponse{Id: s.id}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
|