ref: 5c9a5a1c5e7481ebba418da8a8f17fa14ed85d30
server/grpc/yats-grpc-server.go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/** * Yats - yats * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Paolo Lulli <kevwe.com> * @copyright Paolo Lulli 2024 */ package grpc import ( "google.golang.org/grpc" "log" "net" "yats-server/proto" ) type server struct { proto.UnimplementedYatsGrpcServiceServer } func RunYatsGrpcServer(address string) { lis, err := net.Listen("tcp", address) if err != nil { log.Fatalf("failed to listen: %v", err) } s := grpc.NewServer() proto.RegisterYatsGrpcServiceServer(s, &server{}) log.Printf("Server is running on port %s\n", address) if err := s.Serve(lis); err != nil { log.Fatalf("failed to serve: %v", err) } } |